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.
Explain it simply
Deleting a branch deletes only the label, not the commits. Think of removing a bookmark: the web page is still there until the server cleans it up.
Git still holds those commits, and the reflog remembers the last place HEAD saw them. Look for the line mentioning your branch or its last commit message, copy the hash, and create a new branch there. When you use git branch -d, Git also prints the abbreviated hash when it deletes, so scroll up in your terminal. On GitHub a deleted remote branch from a pull request has a Restore button.
Example
git branch -D feature/payment
# Deleted branch feature/payment (was 4e5f6a7).
git branch feature/payment 4e5f6a7
# or search:
git reflog | grep paymentWhat to say in the interview
"Deleting a branch only removes the pointer. I use git reflog, or the hash printed at deletion, and run git branch name hash to recreate it. It works until unreachable commits are garbage collected."