Interview Q&A / Git & GitHub
Git & GitHub interview questions
Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.
Prefer rapid revision? Practise Git & GitHub short interview answers →
- How can you recover a branch that you deleted by mistake?
Find the branch's last commit hash with git reflog, then recreate it with git branch name hash. The commits are not erased immediately, so recovery works until Git garbage-collects them.
IntermediateQuick answer1 min read - What is git reflog, and how does it help you recover lost commits?
The reflog is a local log of every position HEAD and your branches have been at. If you reset or delete something by mistake, you find the old commit hash in the reflog and point a branch back to it.
IntermediateQuick answer1 min read