Courseiva
Software Development and DesignmediumMultiple SelectObjective-mapped

200-901 Software Development and Design Practice Question

A DevOps engineer is managing a Git repository and wants to discard local changes to a file and revert it to the last committed state. Which TWO commands can accomplish this? (Choose two.)

⚠ Common exam trap

Cisco often tests the distinction between commands that affect the entire repository (like `git reset --hard`) versus those that target a single file (like `git checkout -- <file>` or `git restore <file>`), leading candidates to incorrectly choose `git reset --hard HEAD` when only a single file needs reversion.

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 checkout -- <file>

Both `git checkout -- <file>` and `git restore <file>` discard unstaged local changes to a file, reverting it to the content of the last commit (HEAD). `git checkout -- <file>` is the traditional command, while `git restore <file>` is the newer, more intuitive alternative introduced in Git 2.23. Both operate on the working tree without affecting the staging area or commit history.

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 reset --hard HEAD

    Why it's wrong here

    This resets all files and the index, discarding all changes, but it affects the entire repository, not just one file.

  • git checkout -- <file>

    Why this is correct

    This reverts the file to its state in the index (last staged version) or HEAD if not staged.

  • git stash drop

    Why it's wrong here

    This drops the latest stash, not relevant to discarding changes to a specific file.

  • git revert <file>

    Why it's wrong here

    'git revert' is for undoing commits, not discarding local changes.

  • git restore <file>

    Why this is correct

    This is the modern equivalent of 'git checkout -- <file>' for restoring working tree files.

About these practice questions

This 200-901 question is part of Courseiva's 989-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 by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 200-901 practice question is part of Courseiva's free Cisco 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 200-901 exam.