git cherry-pick 说“...38c74d 是一个合并,但没有给出 -m 选项"; [英] git cherry-pick says "...38c74d is a merge but no -m option was given"

查看:52
本文介绍了git cherry-pick 说“...38c74d 是一个合并,但没有给出 -m 选项";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的主分支中进行了一些更改,并希望将它们带到上游.当我挑选以下提交时.但是,我卡在 fd9f578 上,git 说:

I made some changes in my master branch and want to bring those upstream. When I cherry-pick the following commits. However, I get stuck on fd9f578 where git says:

$ git cherry-pick fd9f578
fatal: Commit fd9f57850f6b94b7906e5bbe51a0d75bf638c74d is a merge but no -m option was given.

git 想告诉我什么,并且挑选正确的东西在这里使用?master 分支确实包含对在上游分支中修改过的文件的更改,所以我确信会有一些合并冲突,但这些冲突并没有太糟糕而无法解决.我知道哪些地方需要进行哪些更改.

What is git trying to tell me and is cherry-pick the right thing to be using here? The master branch does include changes to files which have been modified in the upstream branch, so I'm sure there will be some merge conflicts but those aren't too bad to straighten out. I know which changes are needed where.

这些是我想要向上游提交的提交.

These are the commits I want to bring upstream.

e7d4cff added some comments...
23e6d2a moved static strings...
44cc65a incorporated test ...
40b83d5 whoops delete whitspace...
24f8a50 implemented global.c...
43651c3 cleaned up ...
068b2fe cleaned up version.c ...
fd9f578 Merge branch 'master' of ssh://extgit/git/sessions_common
4172caa cleaned up comments in sessions.c ...

推荐答案

cherry-pick 的工作方式是获取变更集所代表的差异(此时的工作树与其父级的工作树之间的差异),并将其应用到您当前的分支.

The way a cherry-pick works is by taking the diff a changeset represents (the difference between the working tree at that point and the working tree of its parent), and applying it to your current branch.

那么,如果一个提交有两个或更多的父项,它也代表两个或更多的差异——应该应用哪一个?

So, if a commit has two or more parents, it also represents two or more diffs - which one should be applied?

您正在尝试挑选 fd9f578,这是与两个父母的合并.因此,您需要使用 -m 选项告诉cherry-pick 命令应该计算哪个差异.例如,git cherry-pick -m 1 fd9f578 使用父 1 作为基础.

You're trying to cherry pick fd9f578, which was a merge with two parents. So you need to tell the cherry-pick command which one against which the diff should be calculated, by using the -m option. For example, git cherry-pick -m 1 fd9f578 to use parent 1 as the base.

对于您的特定情况,我不能肯定地说,但通常建议使用 git merge 而不是 git cherry-pick.当您挑选一个合并提交时,它会将所有在您未指定到 -m 的父项中所做的更改折叠到该一次提交.你失去了他们所有的历史,把他们所有的差异都放在一起.您的来电.

I can't say for sure for your particular situation, but using git merge instead of git cherry-pick is generally advisable. When you cherry-pick a merge commit, it collapses all the changes made in the parent you didn't specify to -m into that one commit. You lose all their history, and glom together all their diffs. Your call.

这篇关于git cherry-pick 说“...38c74d 是一个合并,但没有给出 -m 选项";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆