Git 反向提交 SourceTree 中的推送合并
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35652427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git reverse commit a pushed merge in SourceTree
提问by Ogglas
I accidentally merged a branch and had "Push changes immediately" checked. Unfortunately I made a merge error and now I wan't to make a reverse commit to remove it. However every time I do it in SourceTree I get the following error:
我不小心合并了一个分支并选中了“立即推送更改”。不幸的是,我犯了一个合并错误,现在我不想进行反向提交来删除它。但是,每次我在 SourceTree 中执行此操作时,都会出现以下错误:
error: Commit X is a merge but no -m option was given. fatal: revert failed
错误:提交 X 是一个合并,但没有给出 -m 选项。致命:恢复失败
Is there any way to do this or do I have to use the terminal for this? Been reading about it but could not find a solution to this specific case.
有什么办法可以做到这一点,还是我必须为此使用终端?一直在阅读它,但找不到解决此特定案例的方法。
回答by edgraaff
You can find answers about how to bring back your branch (or master) back to the state of before it was merged (hard revert). If it's okay to revert everything back to that state, it's fine. But usually I have to revert the merge of a feature branch while preserving commits made after that merge.
您可以找到有关如何将您的分支(或主)恢复到合并前的状态(硬还原)的答案。如果可以将所有内容恢复到那个状态,那就没问题了。但通常我必须恢复功能分支的合并,同时保留合并后所做的提交。
Just do:
做就是了:
git revert -m 1 [copy-paste-the-id-of-the-merge-commit-here]
if necessary, edit conflicts and commit.
如有必要,编辑冲突并提交。
edit: and yes, SourceTree should be passing the -m 1 arguments if you're undoing a merge commit.
编辑:是的,如果您要撤消合并提交,SourceTree 应该传递 -m 1 参数。
回答by Cyan Baltazar
You may want to right click on the latest commit and click:
您可能希望右键单击最新的提交并单击:
"Reset current branch to this commit"
“将当前分支重置为此提交”
and select the Hard mode when prompted.
并在出现提示时选择困难模式。
Important Note: All working copy changes will be discarded upon clicking the hard mode.
重要提示:单击硬模式后,所有工作副本更改都将被丢弃。
Hope this helps!
希望这可以帮助!
Cheers!
干杯!