Challenge - 5 Problems
Reflog Recovery Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of
git reflog after a commit reset?You ran
git reset --hard HEAD~1 to undo the last commit. What will git reflog show as the latest entry?Git
git reset --hard HEAD~1 git reflog
Attempts:
2 left
💡 Hint
Think about what
git reset --hard does to the HEAD pointer.✗ Incorrect
After git reset --hard HEAD~1, the HEAD moves to the previous commit. The reflog records this as a reset action, so the latest entry is reset: moving to HEAD~1.
🧠 Conceptual
intermediate2:00remaining
Which command recovers a lost commit using reflog?
You accidentally lost a commit after a reset. Which command correctly restores the lost commit using reflog?
Attempts:
2 left
💡 Hint
You want to move HEAD back to the lost commit forcibly.
✗ Incorrect
git reset --hard HEAD@{1} moves the HEAD pointer back to the previous state recorded in reflog, restoring the lost commit.
❓ Troubleshoot
advanced2:00remaining
Why does
git reset HEAD@{2} fail to restore a lost commit?You tried
git reset HEAD@{2} to recover a lost commit but it did not work as expected. What is the most likely reason?Attempts:
2 left
💡 Hint
Consider what
git reset does by default without flags.✗ Incorrect
By default, git reset without --hard only moves HEAD and updates the index but does not change the working directory. To fully restore a lost commit state, --hard is needed.
🔀 Workflow
advanced3:00remaining
Order the steps to recover a lost commit using reflog
Arrange the steps in the correct order to recover a lost commit using reflog.
Attempts:
2 left
💡 Hint
Think about finding the commit first, then restoring it, then verifying.
✗ Incorrect
First, find the lost commit in reflog. Then reset hard to that commit. Next, verify with git log. Finally, check your files.
✅ Best Practice
expert3:00remaining
What is the safest way to recover a lost commit without risking current work?
You want to recover a lost commit using reflog but keep your current changes safe. Which approach is best?
Attempts:
2 left
💡 Hint
Think about preserving your current work and avoiding forced resets.
✗ Incorrect
Creating a new branch at the lost commit preserves your current work and allows you to inspect or merge changes safely without resetting your current branch.