Advertisement
nezvers

Recover git branch

Oct 13th, 2023
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | Help | 0 0
  1. ## Pre-requisite: You have to know your last commit message from your deleted branch.
  2. git reflog
  3. # Search for message in the list
  4. # a901eda HEAD@{18}: commit: <last commit message>
  5.  
  6. # Now you have two options, either checkout revision or HEAD
  7. git checkout a901eda
  8. # Or
  9. git checkout HEAD@{18}
  10.  
  11. # Create branch
  12. git branch recovered-branch
  13.  
  14. # You may want to push that back to remote
  15. git push origin recovered-branch:recovered-branch
Tags: git
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement