Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recovering a deleted branch from a remote on Bitbucket (git)

Tags:

git

bitbucket

I want to recover a branch that was deleted from our remote shared repository on Bitbucket. I know that reflog is the way to go with local repositories.

How would I got about achieving this on the remote one?

like image 376
OpherV Avatar asked Mar 24 '13 08:03

OpherV


People also ask

Is it possible to recover deleted branch in Bitbucket?

In the case of manual search using reflog tool, we must be aware that even the Bitbucket in their official documentation recommends a full backup of our project before starting this process. This means that using the GitProtect.io solution will allow us to reverse the lost branch with one click.

Can I recover a deleted branch in git?

A deleted Git branch can be restored at any time, regardless of when it was deleted. Open your repo on the web and select the Branches view. Search for the exact branch name using the Search all branches box in the upper right. Click the link to Search for exact match in deleted branches.


2 Answers

Four years later...

I came across this answer because I deleted a branch through the bitbucket.org UI that a team member wanted restored.

I discovered that git branch --remote shows all the branches on origin, even the ones that are deleted through the UI.

I checked out the origin branch locally with git checkout origin/<branch_name> -b <branch_name>, then did git push -u origin <branch_name> and it showed up in the UI again.

like image 177
Michael Avatar answered Sep 18 '22 01:09

Michael


reflog is still the answer, except you don't have access to the reflog on the remote (Bitbucket ) side.

That means you need to write to Bitbucket support in order for them to restore what you need.

like image 37
VonC Avatar answered Sep 19 '22 01:09

VonC