Question 427 of 510
Scripting, Containers and AutomationhardMultiple ChoiceObjective-mapped

Quick Answer

The answer is the pre-push hook. This is the correct client-side Git hook to enforce tests before a push because it executes after the `git push` command is issued but before any data is transmitted to the remote repository, allowing you to run your test suite locally and abort the push if any tests fail. On the CompTIA Linux+ XK0-005 exam, this scenario tests your understanding of Git hooks as part of version control and automation, often appearing as a scenario where you must choose between client-side hooks like pre-commit and pre-push. A common trap is selecting pre-commit, which runs before the commit itself, not before the push—so it cannot catch issues introduced by combining multiple commits. Remember the memory tip: "Push before you push" — the pre-push hook runs right before the data leaves your machine, making it the ideal gatekeeper for enforcing test success on every push.

XK0-005 Scripting, Containers and Automation Practice Question

This XK0-005 practice question tests your understanding of scripting, containers and automation. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

You are a DevOps engineer managing a Git repository for a large development team. Your CI/CD pipeline runs automated tests on every push. Recently, developers have been pushing commits that break the build. You need to enforce that all commits pass the tests before being pushed to the remote repository. Which Git hook should you implement on the client side?

Question 1hardmultiple choice
Full question →

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-push

The pre-push hook (option D) runs after a `git push` command is issued but before the data is actually sent to the remote repository. This allows you to run tests locally and abort the push if they fail, enforcing that only commits that pass tests are pushed. It is the correct client-side hook for this requirement.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • pre-receive

    Why it's wrong here

    This is a server-side hook, not client-side; you need a hook on the developers' machines.

  • pre-commit

    Why it's wrong here

    Pre-commit runs before the commit is created; developers might still push commits that were created before tests were added.

  • post-commit

    Why it's wrong here

    Post-commit runs after commit but does not block the push; broken commits would still be pushed.

  • pre-push

    Why this is correct

    Pre-push runs after commit but before push, ensuring tests pass before code leaves the local machine.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

CompTIA often tests the distinction between client-side and server-side hooks, and the trap here is that candidates confuse pre-receive (server-side) with pre-push (client-side), thinking any hook that runs 'before receive' will block the push on the client.

Detailed technical explanation

How to think about this question

The pre-push hook receives two parameters: the name of the remote and its URL, and it reads from stdin a list of refs being pushed with their old/new SHA values. This allows the hook to check not just the latest commit but all commits in the push range. A common real-world scenario is running a full test suite or linter in the pre-push hook to catch issues before they reach the shared repository, which is more efficient than relying on server-side hooks that may reject the push after it has been transmitted.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A practitioner preparing for the XK0-005 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related XK0-005 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free XK0-005 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this XK0-005 question test?

Scripting, Containers and Automation — This question tests Scripting, Containers and Automation — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: pre-push — The pre-push hook (option D) runs after a `git push` command is issued but before the data is actually sent to the remote repository. This allows you to run tests locally and abort the push if they fail, enforcing that only commits that pass tests are pushed. It is the correct client-side hook for this requirement.

What should I do if I get this XK0-005 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This XK0-005 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-005 exam.