0
0
Gitdevops~5 mins

Recovering deleted branches in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Agit reflog
Bgit status
Cgit branch -d
Dgit log --oneline
How do you restore a deleted branch named 'feature' at commit abc123?
Agit checkout feature abc123
Bgit branch feature abc123
Cgit restore feature abc123
Dgit reset feature abc123
What does git reflog show?
ACurrent branch status
BAll commits in the repo
CHistory of HEAD changes including branch deletions
DRemote branches
If a branch was deleted a long time ago and reflog is cleared, what is a possible recovery option?
AUse <code>git branch -f</code>
BUse <code>git stash</code>
CRun <code>git clean</code>
DCheck remote repositories or backups
What is the safest way to avoid losing branches accidentally?
APush branches to remote repositories regularly
BDelete branches often
CNever commit changes
DUse <code>git reset --hard</code> frequently
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.