One of your teammates accidentally deleted a branch, and has already pushed the changes to the central git repo. There are no other git repos, and none of your other teammates had a local copy. How would you recover this branch?
How to recover deleted branch in github
Asked by Tawseef Bhat At4 Answers
0
I assume the developer still has his local repo, right? The terinal should have the id of the revision when he pushed the removal... use that ID to create a new branch
git branch blah the-id
If the terminal is already closed, then check git reflog
for the last revision of that branch.
0
Easiest - look into "git reflog" of the teammate's local repo. You'll find last entry when he checked-out the branch last time.
If it's lost locally, you may have access to remote repo - look there for dangling commits. See instructions here: https://softwarebakery.com/recovering-commits-with-git
Just create a new branch on top of the found commit-id