Objective 3.3XK0-005

3.3 Given a scenario, perform basic version control using Git.

Objective 3.3 sits in Scripting, Containers, and Automation, which carries 19% of the Linux+ exam. The questions below are original, written from the official objective title above, and each explanation cites the CompTIA page it rests on.

Objective title verbatim from the official objectives. CompTIA exam page

A worked example

Shown solved, with the whole explanation open: this is what every question here carries.

3-3Scripting, Containers, and AutomationModerate

An administrator wants to discard all uncommitted working-tree changes and match the last commit exactly. Which command does that?

git reset --soft HEADreset --soft leaves the working tree and index unchanged, so the edits remain.
git stash popgit stash pop restores stashed changes rather than discarding current ones.
git revert HEADgit revert creates a new commit undoing a past change, not clearing uncommitted work.
git reset --hard HEADCorrect · your answerCorrect: --hard rewrites the working tree to the target, dropping local edits.

Correct.

Concept

Reset moves the branch pointer, and its mode decides whether the index and working tree are also rewritten to match the target commit.

Why D

git reset --hard HEAD updates the index and overwrites working-tree files to match HEAD, discarding all uncommitted changes.

#git#reset#working-tree

Now you: objective 3.3 questions

No account needed. The explanation opens when you answer.

Sample question 1 of 3

3-3Scripting, Containers, and AutomationHard

An administrator must undo the last commit but keep its changes staged, ready for a new commit. Which reset mode fits?

Sample question 2 of 3

3-3Scripting, Containers, and AutomationHard

After a bad commit was already pushed and pulled by teammates, an administrator must undo it without rewriting shared history. Which command is correct?

Sample question 3 of 3

3-3Scripting, Containers, and AutomationModerate

During a merge an administrator sees conflict markers <<<<<<< in a file. After editing it to resolve the conflict, what completes the merge?

Full Linux+ question bank coming

We’re writing the complete bank from the official objectives right now. Leave your email and we’ll tell you when it ships, nothing else, ever.

Read the sources

These are the official pages the questions above cite. Reading them is studying the objective from the primary source, which is what the explanations point you toward anyway.

More objectives in Scripting, Containers, and Automation