How to restore a deleted branch

'How Do I...' and 'How to...' Guide to Stash



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


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 Stash

2. If you have a backup of your repository, you could try to restore the entire repository back to $STASH_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

最終更新日 2015 年 5 月 25 日


Powered by Confluence and Scroll Viewport.