Recall & Review
beginner
What is the first step to recover a deleted branch in Git?
Use
git reflog to find the commit hash where the branch was last pointing before deletion.Click to reveal answer
beginner
How do you recreate a deleted branch once you have the commit hash?
Run
git branch <branch-name> <commit-hash> to restore the branch at the commit.Click to reveal answer
beginner
What command shows a log of all recent Git actions including branch deletions?
git reflog shows a history of HEAD changes, including branch deletions and checkouts.Click to reveal answer
intermediate
Can you recover a deleted branch if you don't know the commit hash?
Yes, by using
git reflog you can find the commit hash from recent HEAD movements.Click to reveal answer
advanced
What happens if you try to recover a branch that was deleted a long time ago and reflog is expired?
If reflog entries are expired or garbage collected, recovery might not be possible unless you have backups or remote copies.
Click to reveal answer
Which Git command helps you find the commit hash of a deleted branch?
✗ Incorrect
git reflog tracks all recent HEAD changes, including branch deletions, so you can find the commit hash.
How do you restore a deleted branch named 'feature' at commit abc123?
✗ Incorrect
git branch feature abc123 recreates the branch 'feature' at the commit abc123.
What does
git reflog show?✗ Incorrect
git reflog shows the history of HEAD movements, useful for recovering deleted branches.
If a branch was deleted a long time ago and reflog is cleared, what is a possible recovery option?
✗ Incorrect
Remote repositories or backups may still have the branch if reflog is expired locally.
What is the safest way to avoid losing branches accidentally?
✗ Incorrect
Pushing branches to remote repositories keeps a backup copy to recover from if deleted locally.
Explain the steps to recover a deleted Git branch using reflog.
Think about how Git tracks HEAD changes and how to create a branch at a specific commit.
You got /3 concepts.
What are the limitations of recovering deleted branches in Git?
Consider what happens if Git cleans up old history or if no backups exist.
You got /4 concepts.