drizzt13
drizzt13

Reputation: 649

recover github deleted remote branch that wasn't merged into master

I've accidentally deleted a branch on my github repository.

I've searched up for a solution, and tried the methods mentioned here and here, but because I never merged that branch into master - I don't see it in the reflog at all.

My only local working copy that still has that branch on it is unreachable for few days because of technical issues.
Is there any way to recover that deleted branch?

Upvotes: 1

Views: 719

Answers (2)

insureD
insureD

Reputation: 1

If you are not working through GitHub(say BitBucket..) and the branch you have in your local does not lave the log for unmerged branches in reflog, then there are two options 1) find a team member who has last fetched from the repo and can access all the branches in his fetched repo. He can then transfer to each of the remote branch and push that particular code up to the repo. You can go back in your other workspaces/folders to see if you have fetched from any other feature branches and can do the same. 2) ask all other team members who are working on their local branch to push their code up the repo recreating the structure for (only live) branches.

This will be still incomplete as the restructuring will miss the commits after the last fetch till the current merge and the tree history will be modified in its refs . But at least it will avoid complete loss of code base and history.

Upvotes: 0

VonC
VonC

Reputation: 1324318

The quickest way remains to write to GitHub support: they do have access to the refleg of the GitHub repo, and can restore that branch for you.

Then a simple fetch would allow you to recover that same branch in your local repo.

Upvotes: 1

Related Questions