git merge --no-commit vs git cherry-pick --no-commit
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20837080/
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 merge --no-commit vs git cherry-pick --no-commit
提问by whenov
Is there any difference between git merge --no-commit
and git cherry-pick --no-commit
?
有什么区别git merge --no-commit
和git cherry-pick --no-commit
?
And is there any difference in history if I commit after these two commands?
如果我在这两个命令之后提交,历史上有什么不同吗?
回答by gturri
If you commit after git merge --no-commit
, you'll actually get a merge commit. Whereas after a git cherry-pick --no-commit
you'll get a commit with a single parent.
如果你在之后提交git merge --no-commit
,你实际上会得到一个合并提交。而在 a 之后,git cherry-pick --no-commit
您将获得与单亲的提交。
Hence, yes, there is a difference between those two commands.
因此,是的,这两个命令之间存在差异。
In particular if you have something like
特别是如果你有类似的东西
A -- B -- C
\ L HEAD
\
-- D -- E
If you cherry-pick
commit E
, you won't get modifications of commit D
. Whereas if you merge
, you'll get both.
如果你cherry-pick
commit E
,你不会得到 commit 的修改D
。而如果你merge
,你会得到两者。
回答by Ahmed Siouani
While git-mergeis used to join two or more development histories together, git-cherry-pickis used to apply changes introduced by some existing commits.
虽然混帐合并是用来连接两个或更多的发展历史一起,git的樱桃挑选用于应用通过一些现有的提交引入的更改。
So then, once you commit after performing a git-merge, Git will add what's called a merge commit. In the other side, when cherry-pick(ing)commits, git will apply the changes introduced by these commits on the top of your working tree (There's no fusion between two or many branches). Put another way, Commits are cloned and put on top of your branch.
因此,一旦您在执行git-merge后提交,Git 将添加所谓的合并提交。另一方面,当cherry-pick(ing)提交时,git 会将这些提交引入的更改应用到工作树的顶部(两个或多个分支之间没有融合)。换句话说,提交被克隆并放在你的分支之上。
Take a look at Git Cherry-pick vs Merge Workflowto undestand the differences based on a repo maintainer real needs.
看看Git Cherry-pick 与 Merge Workflow以了解基于 repo 维护者实际需求的差异。