Challenge - 5 Problems
Reflog Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateWhat 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
intermediateWhat 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
advancedHow 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
advancedWhy 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
expertWhat 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.
