How to undelete a branch on github?

后端 未结 3 1208
醉梦人生
醉梦人生 2020-12-08 07:36

It seems that I delete a branch on github when I should not do it.

What I did was as follow:

1- I add a new .gitignore to my system

2- I use

<
3条回答
  •  醉梦人生
    2020-12-08 08:08

    If you know the last commit message of the deleted branch you can do this:

    git reflog
    

    # search for message

    fd0e4da HEAD@{14}: commit: This is the commit message I want
    

    # checkout revision

    git checkout fd0e4da 
    

    or

    git checkout HEAD@{14}
    

    # create branch

    git branch my-recovered-branch
    

    # push branch

    git push origin my-recovered-branch:my-recovered-branch
    

提交回复
热议问题