Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

git undo deleted local branch

git reflog //You can use git reflog to find the SHA1 of the last commit of the branch.
From that point, you can recreate a branch using

git branch branchName <sha1>

user@MY-PC /C/MyRepo (master)
$ git branch -D master2
Deleted branch master2 (was 130d7ba).    <-- This is the SHA1 we need to restore it!

user@MY-PC /C/MyRepo (master)
$ git branch master2 130d7ba
 
PREVIOUS NEXT
Tagged: #git #undo #deleted #local #branch
ADD COMMENT
Topic
Name
2+3 =