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 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>
Please take a *full backup* before performing this