简体   繁体   English

git cherry-pick由于合并冲突而失败

[英]git cherry-pick failing because of merge conflict

I am using git cherry-pick to add specific commit SHAs to a particular branch: 我正在使用git cherry-pick将特定的提交SHA添加到特定分支:

git cherry-pick 12345
error: commit 12345 is a merge but no -m option was given.
fatal: cherry-pick failed

(Pretend 12345 is a commit SHA.) (假装12345是提交SHA。)

I've tried several other variations but they all fail: 我尝试了其他几种变体,但都失败了:

git cherry-pick 12345 -m
git cherry-pick -m 12345
etc.

Not sure how to interpret the error message or figure out what the fix is. 不确定如何解释错误消息或找出解决方法。 Any ideas? 有任何想法吗?

Yes, the sequence of commits passed to git cherry-pick indeed matters. 是的,传递给git cherry-pick的提交顺序确实很重要。

Consider your first commit A introduced a new line, and the next commit B modified the same line. 考虑您的第一次提交A引入了新行,而下一次提交B修改了同一行。 if the commits are picked in the wrong order, then commit B has nothing to patch, even if that didn't fail, then commit A would add the un-patched line back, probably not what you want, right? 如果以错误的顺序选择了提交,那么提交B也没有补丁,即使那没有失败,那么提交A也会添加未打补丁的行,可能不是您想要的,对吧?

And regarding merge commits, if it introduced changes, then it must be included, too. 关于合并提交,如果它引入了更改,那么也必须将其包括在内。

Also, usually you don't pass a long list of commits to git cherry-pick , you can use revision range syntax to specify a series of commits, please refer to the EXAMPLES section in the manual: https://git-scm.com/docs/git-cherry-pick 此外,通常您不会将一连串的提交提交给git cherry-pick ,可以使用修订范围语法指定一系列提交,请参阅手册中的“ 示例”部分: https:// git-scm。 COM /文档/ git的樱桃挑选

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM