[英]Committed to the correct branch, but then pushed the wrong branch, how to undo the push?
I made some changes on branch1
, committed them, checked out branch2
, made changes and committed them.我对branch1
进行了一些更改,提交了它们,签出了branch2
,进行了更改并提交了它们。
I pushed branch1
to GitHub by mistake.我错误地将branch1
推送到了 GitHub。
I then pushed branch2
.然后我推了branch2
。
Because I only meant to push branch2
, I want to undo the branch1
push.因为我只想推送branch2
,所以我想撤消branch1
推送。
Basically I did the following:基本上我做了以下事情:
git checkout -b branch1
//make some changes on branch1
git commit -am "changes on branch1"
git checkout -b branch2
//make some different changes on branch2
git commit -am "changes on branch2"
git push origin branch1 //whoops!
git push origin branch2 //this is what I meant to do
I want to undo the branch1
push but not the branch2
push;我想撤消branch1
推送而不是branch2
推送; how do I do this?我该怎么做呢?
Assuming you only pushed a single change假设您只推送了一个更改
git push origin +branch1^:branch1
will roll back the branch1 head on origin to the previous commit.将原点上的 branch1 头回滚到上一个提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.