Reflog — Recovering Lost Commits — Concept Check
Questions on Reflog — Recovering Lost Commits. The reflog is Git's safety net — it records every change to HEAD and branch pointers for 90 days. You can recover commits lost to reset --hard, dropped rebases, or accidental branch deletions.
Questions in this quiz
8 questions on Reflog — Recovering Lost Commits — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You accidentally ran 'git reset --hard HEAD~3'. How can you recover the lost commits?
- AUse 'git fsck' to automatically restore lost commits
- BWait 90 days for Git to auto-recover
- CUse 'git reflog' to find and reset to the lost commit
- DUse 'git revert' to undo the reset
2.After performing a 'git reset --hard', you realize you've lost important work. What should you do first?
- AUse 'git merge' to bring back the lost commits
- BRun 'git gc' to clean up and recover space
- CRun 'git reflog' to identify the lost commits
- DImmediately clone the repository again
3.A developer claims that running 'git reset --hard HEAD' permanently deletes commits. What's the truth?
- AThe commits are deleted and unrecoverable
- BThe commits are moved to a hidden branch
- CThe commits are stored in the stash
- DThe commits can be recovered using 'git reflog'
4.You've deleted a branch by mistake. How can you recover it using reflog?
- AUse 'git stash apply' to restore the branch
- BRecreate the branch from the main branch
- CBranches cannot be recovered once deleted
- DFind the branch's last commit in reflog and checkout
5.What does 'git reflog' show you?
- AOnly the current branch history
- BAll branches in the repository
- COnly the last commit hash
- DRecent HEAD positions with operations
6.Which command safely recovers lost commits without affecting current work?
- Agit revert HEAD@{n}
- Bgit merge HEAD@{n}
- Cgit reset --hard HEAD@{n}
- Dgit switch -c new-branch HEAD@{n}
7.A colleague suggests that 'git fsck' can directly restore lost commits. Is this true?
- ANo, it only works with branches
- BNo, it only finds dangling commits
- CYes, it restores them automatically
- DYes, but only if run immediately
8.How long does Git keep reflog entries by default?
- A90 days
- B60 days
- C120 days
- D30 days