Courseiva

XK0-006 Automation, Orchestration, and Scripting Practice Question

A Linux administrator is using Git to manage a configuration repository. They need to undo a commit that has already been pushed to a shared remote repository, without rewriting history. Which command should they use?

⚠ Common exam trap

The trap here is thinking that any undo operation requires rewriting history, but `git revert` specifically adds a new commit to undo changes without altering past commits.

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

✓

git revert <commit>

To undo a commit that has already been pushed without rewriting history, `git revert` is the correct choice. It creates a new commit that reverses the changes, preserving the original commit in the history. This is safe for collaboration because it does not require force pushing. Other commands like `reset`, `commit --amend`, or `rebase` rewrite history and should be avoided in shared repositories.

Answer analysis

Option-by-option breakdown

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

  • ✗

    git rebase -i <commit>

    Why it's wrong here

    Interactive rebase allows rewriting history by editing, squashing, or removing commits. Like `reset`, it alters existing commits and should not be used on commits that have been pushed to a shared repository. It would require a force push and could cause conflicts for other developers. It is not the correct tool for undoing a public commit.

  • ✗

    git reset --hard <commit>

    Why it's wrong here

    `git reset --hard` moves the branch pointer to a previous commit and discards all changes after it. This rewrites history, which is problematic if the commit has been pushed to a shared repository because it forces other developers to reconcile divergent histories. It should be avoided in shared workflows.

  • ✗

    git commit --amend

    Why it's wrong here

    `git commit --amend` modifies the most recent commit, replacing it with a new commit. This rewrites history and is only safe for local, unpushed commits. If the commit has been pushed, amending it would require a force push, which can disrupt other collaborators. It is not suitable for undoing a pushed commit.

  • ✓

    git revert <commit>

    Why this is correct

    `git revert` creates a new commit that undoes the changes introduced by the specified commit. This is safe for shared repositories because it does not alter existing history; it adds a new commit that reverses the changes. It is the recommended way to undo changes that have been pushed, as it preserves the commit history for all collaborators.

About these practice questions

This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.