How to restore a deleted branch

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

There are three known ways to restore a deleted branch:

1. Being the easiest is where if anyone has a local copy of the repository, that person can just push into Bitbucket Server

2. If you have a backup of your repository, you could try to restore the entire repository back to $BITBUCKET_HOME directory

3. Using Git: 

- First, on your local repository, perform git reflog. This will list down all previous HEADs. Find the latest commit hash for the branch that you have deleted.
- Once you have the commit hash, perform git reset --hard <commit>. This will revert the HEAD back to the latest commit on the branch
- Recreate the branch again and checkout to that new branch git checkout -b <branchname>
- Then push the branch, git push origin <branchname>

(warning) Please take a full backup before performing this


For instruction on how to detect deleted branches, refer to the How to identify a deleted branch page.

Last modified on Mar 6, 2024

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.