通过拉取请求撤消合并? [英] Undo a merge by pull request?
问题描述
有一个更好的回答,但我可以逐步解决这个问题。
您需要获取并签出最新的上游更改,例如:
GIT中取上游
git的结帐上游/主-b还原/约翰/ foo_and_bar
看看提交日志,你应该找到类似这样的内容:
提交b76a5f1f5d3b323679e466a1a1d5f93c8828b269
合并:9271e6e a507888
作者:蒂姆·汤姆< tim@tom.com>
日期:星期一4月29日06:12:38 2013 -0700
从john / foo_and_bar合并拉请求#123
添加foo和bar
commit a507888e9fcc9e08b658c0b25414d1aeb1eef45e
作者:John Doe< john@doe.com>
日期:周一29四月12点十三分29秒2013 +0000
加入吧
犯470ee0f407198057d5cb1d6427bb8371eab6157e
作者:李四<约翰@母鹿.COM>
Date:Mon Apr 29 10:29:10 2013 +0000
添加foo
现在,您希望恢复整个拉取请求,并具有稍后恢复的能力。
为此,您需要获取合并提交的ID 。
在上面的示例中,合并提交 是合并请求#123 ... 。。 这两个改变(添加栏和添加foo),你将最终在一次提交中恢复整个请求,你可以稍后恢复并保留历史变化的清洁:
GIT中恢复-m 1 b76a5f1f5d3b323679e466a1a1d5f93c8828b269
Someone accepted a pull request which they shouldn't have. Now we have a bunch of broken code merged in. How do you undo a pull request? I was just going to revert the changes to the commit just before the merge, but I noticed that it merged in a bunch of commits. So now there are all these commits from this person from days before the merge. How do you undo this?
There is a better answer to this problem, though I could just break this down step-by-step.
You will need to fetch and checkout the latest upstream changes like so, e.g.:
git fetch upstream
git checkout upstream/master -b revert/john/foo_and_bar
Taking a look at the commit log, you should find something similar to this:
commit b76a5f1f5d3b323679e466a1a1d5f93c8828b269 Merge: 9271e6e a507888 Author: Tim Tom <tim@tom.com> Date: Mon Apr 29 06:12:38 2013 -0700 Merge pull request #123 from john/foo_and_bar Add foo and bar commit a507888e9fcc9e08b658c0b25414d1aeb1eef45e Author: John Doe <john@doe.com> Date: Mon Apr 29 12:13:29 2013 +0000 Add bar commit 470ee0f407198057d5cb1d6427bb8371eab6157e Author: John Doe <john@doe.com> Date: Mon Apr 29 10:29:10 2013 +0000 Add foo
Now you want to revert the entire pull request with the ability to unrevert later. To do so, you will need to take the ID of the merge commit.
In the above example the merge commit is the top one where it says "Merged pull request #123...".
Do this to revert the both changes ("Add bar" and "Add foo") and you will end up with in one commit reverting the entire pull request which you can unrevert later on and keep the history of changes clean:
git revert -m 1 b76a5f1f5d3b323679e466a1a1d5f93c8828b269
这篇关于通过拉取请求撤消合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!