Microsoft DevOps Engineer Expert AZ-400 Practice Question
A co-worker accidentally rewrote the history of the remote release branch by using git reset --hard and then force-pushing the changes. This action removed the two most recent commits. After running git fetch in your local repository to synchronize with the remote, you are tasked with recovery. Which command should you execute to find the hashes of the lost commits?
git reflog records every change to the tips of references (like branches) in the local repository, including those created by reset, merge, and pull operations. Because you have already fetched the force-pushed changes, the reflog for your remote-tracking branch (origin/release) contains the history of its tip, including the hash it pointed to before the fetch. By inspecting the reflog, you can find the previous hash and restore the branch. The default retention for unreachable reflog entries is 30 days. git fsck --lost-found can find dangling objects but lacks the chronological context of the reflog, making it harder to identify the correct commit. git log --graph only shows commits in the current reachable history and will not show the lost commits. git stash list is for managing stashed changes and is unrelated to commit history recovery.
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 git reflog, and how does it help in commit recovery?
Open an interactive chat with Bash
What is the difference between git reflog and git fsck --lost-found?
Open an interactive chat with Bash
How does git fetch affect the reflog for remote-tracking branches?
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 .