git 多次提交樱桃采摘

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20698614/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:29:13  来源:igfitidea点击:

Multiple commits cherry-picking

gitgit-cherry-pick

提问by Nitu Dhaka

I have 33 commits in the main branch that are meshed up. Now I need to maintain the record neatly. So now I have created feature branches and I'm trying to classify those 33 commits in different feature branches. So can it be possible to pick multiple commits at a time to copy in the relevant feature branch? And I am also facing its conflicts when I tried multiple commits with the cherry-pick command.

我在主分支中有 33 个提交,这些提交是网格化的。现在我需要整齐地维护记录。所以现在我已经创建了功能分支,我正在尝试将这 33 个提交分类到不同的功能分支中。那么是否可以一次选择多个提交以复制到相关功能分支中?当我尝试使用cherry-pick 命令进行多次提交时,我也面临着它的冲突。

git cherry-pick A B C

here A, B, C are the commits' hashcode.

这里 A、B、C 是提交的哈希码。

回答by silvio

You do it correct. The synopsis is

你做对了。概要是

git cherry-pick [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...

git cherry-pickgoes from left to right commit. You can order how you want. If you have a conflict you have three choices. you can git cherry-pick --quit(stop cherry-picking and let your tree in his current state), git cherry-pick --abort(stop cherry-picking and reset your branch to the state where he was before you start git cherry-pick) or resolve this conflict with an editor or with git mergetooland then git cherry-pick --continuego to next commit in your list.

git cherry-pick从左到右提交。您可以根据需要订购。如果你有冲突,你有三个选择。你可以git cherry-pick --quit(停止樱桃采摘,让你的树处于当前状态),git cherry-pick --abort(停止樱桃采摘并将你的分支重置到你开始之前的状态git cherry-pick)或者用编辑器解决这个冲突git mergetool,然后git cherry-pick --continue转到下一步在您的列表中提交。

回答by mockinterface

If you need to maintain the record neatly you are better off with creating a topic branch and running git rebase -i <commit before the 33rd>, an interactive rebase. Follow the instructions for dropping commits. This should be simpler than cherry-picking so many commits in a particular strict order.

如果您需要整洁地维护记录,最好创建一个主题分支并运行git rebase -i <commit before the 33rd>交互式变基。按照删除提交的说明进行操作。这应该比以特定的严格顺序挑选如此多的提交更简单。