如何在github上取消删除分支? [英] How to undelete a branch on github?
问题描述
我做的是如下:
1-我为我的系统添加一个新的.gitignore
2-我使用
git rm -r --cached。
git add。
git commit -m.gitignore现在正在运行
当我这样做时,我我的本地系统上有一个分支,但服务器有两个分支。
然后我把我的分支推到服务器上,因为我没有第二个分支,第二个分支被删除了我怎样才能把它带回来?
我使用Github作为远程服务器。
如果你知道被删除分支的最后一条提交消息,你可以这样做:$ b $ b
git reflog
#搜寻讯息
fd0e4da HEAD @ {14}:commit:这是我想要的提交消息
#结帐修订
git checkout fd0e4da
或
git checkout HEAD @ {14}
#create branch
git分支my-recov ered-branch
#push branch
git push origin my-recovered-branch:my-recovered-branch
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
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
When I did this, I had one branch on my local system but the server had two branch.
Then I pushed my branches to server and since I had not the second branch, the second branch was deleted on server.
How can I bring it back?
I am using Github as remote server.
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
这篇关于如何在github上取消删除分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!