Microsoft DevOps Engineer Expert AZ-400 Practice Question
Your team's Azure Repos Git repository has a shared branch named feature-alpha. A teammate accidentally executed git reset --hard HEAD~3 followed by git push --force, removing the last three commits from the remote branch. You have an existing local clone of the repository and just ran git fetch. You must now restore feature-alpha on the server. Which Git command should you run first in your local repository to locate the lost commit IDs?
After a force-push rewrites a remote branch's history, the lost commit objects still exist on the server for a time but are no longer referenced by the branch tip. When you run git fetch in your local repository, your remote-tracking branch (origin/feature-alpha) is updated to match the new, incorrect tip. Critically, Git records this change in your local reflog for that remote-tracking branch. By running git reflog origin/feature-alpha, you can inspect the recent history of that reference and find the commit SHA it pointed to just before the fetch updated it. Once you have the correct SHA, you can restore the branch on the remote (e.g., git push origin <sha>:refs/heads/feature-alpha). The other commands are incorrect; git revert creates new commits instead of restoring old ones, git cherry-pick requires you to already know the commit SHA, and git fetch --force is not the correct command for discovering lost commit hashes.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a Git reflog, and how does it work?
Open an interactive chat with Bash
What does `git reset --hard` do, and how does it differ from a soft reset?
Open an interactive chat with Bash
How is `git push --force` different from a regular `git push`?
Open an interactive chat with Bash
What is a Git reflog and why is it useful?
Open an interactive chat with Bash
How does `git reset --hard HEAD~3` differ from other reset types?
Open an interactive chat with Bash
Why is force-pushing (`git push --force`) risky in Git workflows?
Open an interactive chat with Bash
Microsoft DevOps Engineer Expert AZ-400
Design and implement a source control strategy
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .