Can I recover a branch after its deletion in Git?

后端 未结 20 2134
广开言路
广开言路 2020-11-22 05:53

If I run git branch -d XYZ, is there a way to recover the branch? Is there a way to go back as if I didn\'t run the delete branch command?

20条回答
  •  臣服心动
    2020-11-22 06:29

    I did this on the computer which i delete the branch:

    git reflog

    response:

    74b2383 (develope) HEAD@{1}: checkout: moving from master to develope
    40ef328 (HEAD -> master, origin/master, origin/HEAD) HEAD@{2}: checkout: moving from develope to master
    74b2383 (develope) HEAD@{3}: checkout: moving from master to develope
    40ef328 (HEAD -> master, origin/master, origin/HEAD) HEAD@{4}: reset: moving to HEAD
    40ef328 (HEAD -> master, origin/master, origin/HEAD) HEAD@{5}: clone: from http://LOCALGITSERVER/myBigProject/Android.git
    

    and i retrieve the branch with this command:

    git checkout -b newBranchName 74b2383

提交回复
热议问题