Can I recover a branch after its deletion in Git?

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

    Adding to tfe answer: there is also the git-resurrect.sh script in the contrib/ area of the Git sources (in git.git repository), which might help you.

    git-resurrect attempts to find traces of a branch tip called , and tries to resurrect it. Currently, the reflog is searched for checkout messages, and with -r also merge messages. With -m and -t, the history of all refs is scanned for Merge into other/Merge into (respectively) commit subjects, which is rather slow but allows you to resurrect other people's topic branches.

提交回复
热议问题