Answers for "git undo deleted local branch"

0

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
Posted by: Guest on July-30-2021
-1

how to restore deleted branch in git

Yes, you should be able to do git reflog --no-abbrev and find the SHA1 for 
the commit at the tip of your deleted branch, then just git checkout [sha].
And once you're at that commit, you can just git checkout -b [branchname] to
recreate the branch from there.
Posted by: Guest on April-15-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language