Beginner LevelGit & GitHub
What is git reflog and how does it recover "lost" commits or deleted branches?
❓ Interview Prompt: Explain Reference Logs (reflog), recording HEAD pointer movements, and recovering deleted branches or reset commits.
git reflog (Reference Log) records every local pointer movement of HEAD (commits, checkouts, rebased commits, resets) in .git/logs/HEAD. Recover lost commits by running git reflog and git reset --hard <reflog-hash>.
Code Implementation Example
bash
git reflog
# Output: e5f6g7h HEAD@{1}: commit: feat: critical new feature
git reset --hard e5f6g7h💡Recovering lost commits using git reflog.
🎯 Interview Key Takeaway
Use git reflog to locate past HEAD pointer hashes and recover deleted branches or hard-reset commits.
#git reflog#Disaster Recovery#Beginner
Back to all Git & GitHub Questions→