Can I recover a branch after its deletion in Git?

后端 未结 20 2445
广开言路
广开言路 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:45

    If you like to use a GUI, you can perform the entire operation with gitk.

    gitk --reflog
    

    This will allow you to see the branch's commit history as if the branch hadn't been deleted. Now simply right click on the most recent commit to the branch and select the menu option Create new branch.

提交回复
热议问题