Skip to content

Instantly share code, notes, and snippets.

@umayr
Created April 1, 2016 11:41
Show Gist options
  • Save umayr/b95e11d5f22c24a872ef95d215ba2ab1 to your computer and use it in GitHub Desktop.
Save umayr/b95e11d5f22c24a872ef95d215ba2ab1 to your computer and use it in GitHub Desktop.
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
# Create branch
git branch recovered-branch
# You may want to push that back to remote
git push origin recovered-branch:recovered-branch
@jpinas1998
Copy link

Thx!!!!

@brionace
Copy link

Ta!

@amolak21
Copy link

I know everybody is already thanking you but you deserve it : THANKYOU

@JonathanRoncancio-at
Copy link

Nos has salvado, estamos agradecidos!
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment