Challenge - 5 Problems
Reflog Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What does the command
git reflog show?You run
git reflog in your repository. What output do you expect to see?Git
git reflogAttempts:
2 left
💡 Hint
Think about what 'reflog' tracks in Git.
✗ Incorrect
git reflog shows a history of where HEAD has pointed recently, including commits you may have lost track of.
💻 Command Output
intermediate1:30remaining
What is the output of
git reflog show HEAD@{2}?Assuming your reflog has at least 3 entries, what does this command display?
Git
git reflog show HEAD@{2}
Attempts:
2 left
💡 Hint
HEAD@{n} refers to the nth previous position of HEAD.
✗ Incorrect
HEAD@{2} means the HEAD position two moves ago, so this shows that commit's details.
🔀 Workflow
advanced2:30remaining
How to recover a lost commit using reflog?
You accidentally reset your branch and lost a commit. Which sequence of commands correctly recovers the lost commit using reflog?
Attempts:
2 left
💡 Hint
First find the commit, then create a branch from it.
✗ Incorrect
First, use git reflog to find the lost commit hash. Then checkout that commit, create a new branch, and switch to it.
❓ Troubleshoot
advanced2:00remaining
Why does
git reflog not show a lost commit?You lost a commit but
git reflog does not list it. What is the most likely reason?Attempts:
2 left
💡 Hint
Reflog entries expire after some time or cleanup.
✗ Incorrect
Reflog entries expire after a default time (usually 90 days) or can be cleaned manually, so old commits may disappear from reflog.
✅ Best Practice
expert2:00remaining
What is the best practice to avoid losing commits that reflog might not recover?
Which option is the best practice to ensure commits are not lost even if reflog expires or is cleaned?
Attempts:
2 left
💡 Hint
Think about how to keep commits safe beyond local history.
✗ Incorrect
Pushing commits to a remote repository backs them up safely, preventing loss even if local reflog is cleaned.