Courseiva
hardMultiple ChoiceObjective-mapped

XK0-006 Practice Question: A DevOps team wants to automatically run tests…

A DevOps team wants to automatically run tests before every commit in a local Git repository. Which Git hook should be used?

⚠ Common exam trap

Many exam-takers confuse the timing of Git hooks: candidates often pick pre-push because they think of 'testing before pushing,' but the question explicitly asks about 'before every commit,' which requires the pre-commit hook.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

pre-commit

The pre-commit hook runs before a commit is created, making it the correct choice for automatically running tests before every commit in a local Git repository. This hook can validate code quality, run unit tests, or check for syntax errors, and if it exits with a non-zero status, the commit is aborted.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • post-receive

    Why it's wrong here

    This is a server-side hook, not suitable for client-side enforcement.

  • pre-commit

    Why this is correct

    This hook is triggered before the commit is recorded, allowing tests to prevent a failing commit.

  • post-commit

    Why it's wrong here

    This hook runs after the commit is already created, so it cannot prevent a bad commit.

  • pre-push

    Why it's wrong here

    This hook runs before pushing to a remote, but the commit is already in the local repository.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.