Short and working solution to restore deleted git branch. If you remember branch name you’re half way to success.
sha
of the commit you want to checkout togit reflog
# it'll return something like
# c518a26 (HEAD -> fixes, origin/fixes) HEAD@{0}: commit (merge): Conflicts resolved
# 821eb31 HEAD@{1}: checkout: moving from master to fixes
# eccb1e4 (origin/master, master) HEAD@{2}: checkout: moving from fixes to master
# eccb1e4 (origin/master, master) HEAD@{3}: checkout: moving from master to fixes
# eccb1e4 (origin/master, master) HEAD@{4}: checkout: moving from fixes to master
# c431f5c HEAD@{5}: checkout: moving from master to fixes
# eccb1e4 (origin/master, master) HEAD@{6}: checkout: moving from fixes to master
# eccb1e4 (origin/master, master) HEAD@{7}: checkout: moving from master to fixes
# eccb1e4 (origin/master, master) HEAD@{8}: pull origin master: Fast-forward
# c431f5c HEAD@{9}: checkout: moving from fixes to master
# 821eb31 HEAD@{10}: commit: My fixes, probably to be dropped
git co -b <<branch>> <<sha>>
# in my example it was:
git co -b fixes 821eb31
Use it. You’ll thank me later!
Comments
Empty! You must sign in to add comments.