git 跳过特定提交时如何变基?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12604824/
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
How do I rebase while skipping a particular commit?
提问by Phillip
Is there a way to rebase a branch onto another while skipping a particular (conflicting) commit on the other branch?
有没有办法在跳过另一个分支上的特定(冲突)提交的同时将一个分支重新绑定到另一个分支上?
For example, I want to rebase mybranch
onto master
, but master contains a commit that will conflict with the commits in master, so I prefer to undo that commit completely.
例如,我想变基mybranch
到master
,但是 master 包含一个与 master 中的提交冲突的提交,所以我更喜欢完全撤消该提交。
-o-o-o-o-o-x-o-o-o-o master
|
o-o-o-o mybranch
x marks the conflicting commit.
x 标记冲突提交。
回答by Sergey K.
Use interactive rebase:
使用交互式变基:
git rebase -i master
An editor will open and you will have a list of commits like this:
将打开一个编辑器,您将拥有一个像这样的提交列表:
pick b8f7c25 Fix 1
pick 273b0bb Fix 2
pick 6aaea1b Fix 3
Just delete the commit you want to skip. It will be omitted while rebasing your branch onto master.
只需删除您要跳过的提交。将您的分支重新设置为 master 时,它将被省略。
P.S.If you cannot see the editor, please, refer to this question for solution: How can I set up an editor to work with Git on Windows?
PS如果你看不到编辑器,请参考这个问题的解决方法:How can I set an editor to work with Git on Windows?