简体   繁体   English

提交了正确的分支,但是又推错了分支,如何撤消推?

[英]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.

相关问题 如何在错误的分支上撤消git push - How to undo a git push on the wrong branch Git:拉错了分支,然后推动了合并。如何撤消? - Git: Pulled the wrong branch, then pushed the merge. How to undo? 推送到错误的分支并想重新推送到正确的分支 - Pushed to the wrong branch and want to repush to the correct branch 将 Master 合并到分支中,然后提交并将更改推送到分支。 如果没有强制推动,这怎么能撤消? - Merged Master into branch then committed and pushed changes to branch. How can this be undone without a force push? 如何撤消分支推向高手 - How to undo branch push to master 如何进行提交到错误分支的相同更改并应用于正确的分支? - How to make the same changes that were committed to a wrong branch and apply on the correct branch? 如何撤消合并的分支,然后将其推送到Github - How to undo a merged branch and then push it to Github Git-如何撤消在错误的本地分支中的提交? - Git - How to undo commit in wrong local branch? 将功能分支合并并推送到错误的远程分支。 怎么修? - Merged and pushed feature branch to the wrong remote branch. How to fix? 如何撤消 VS Code 中远程和本地分支的推送提交? - How to undo a pushed commit from remote and local branch in VS Code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM