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

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

问题描述

我在主分支上做了一些改动,想把这些分支带到上游。当我挑选以下提交时,我遇到fd9f578,git说:

  $ git cherry-pick fd9f578 
致命:提交fd9f57850f6b94b7906e5bbe51a0d75bf638c74d是一个合并,但没有-m选项被给出。

git试图告诉我什么是樱桃选择在这里使用的正确的东西?主分支确实包含对上游分支中已修改的文件的更改,所以我确定会有一些合并冲突,但这些冲突并不太难以理顺。我知道需要在哪些地方进行更改。



这些是我想要带到上游的提交。

  e7d4cff添加了一些评论... 
23e6d2a移动了静态字​​符串...
44cc65a合并测试...
40b83d5 whoops删除了whitspace ...
24f8a50实现了global.c ...
43651c3清理了...
068b2fe清理了version.c ...
fd9f578合并分支'ssh'ssh:// extgit / git / sessions_common
4172caa清理了sessions.c中的注释...


解决方案 div>

Cherry-pick的工作方式是通过差异表示变化集(表示当前工作树与其父代的工作树之间的差异),并将其应用于当前分支。



所以,如果一个提交有两个或更多的父母,它也代表两个或更多的差异 - 应该应用哪一个?



你正在尝试樱桃选择 fd9f578 ,这是与tw合并o父母。所以你需要通过使用 -m 选项来告诉cherry-pick命令应该计算哪一个差值。例如, git cherry-pick -m 1 fd9f578 以parent 1为基础。



我可以'对于你的特定情况,肯定会说,但是使用 git merge 而不是 git cherry-pick 通常是可取的。在选择合并提交时,它会将您未指定为 -m 的父级中所做的更改全部合并到一次提交。你失去了他们所有的历史,并且把所有的差异都归结于一起。你的电话。


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.

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 ...

解决方案

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?

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.

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天全站免登陆