git Cherry pick 显示没有 -m 选项被给出错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36975986/
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
Cherry pick shows no -m option was given error
提问by Akash Jain
I have two branch master and development
我有两个分支 master 和 development
I need to get some commit id from development branch in master branch so I do it by cherry-pick but it shows me some error
我需要从 master 分支的 development 分支中获取一些提交 id,所以我通过cherry-pick 来完成,但它显示了一些错误
$> git cherry-pick cf0d52b
error: Commit cf0d52b900f990300c3aa17936ddbae1476d461a is a merge but no -m option was given.
fatal: cherry-pick failed
I am not getting this error, why this error comes and how will I get rid of this.
我没有收到此错误,为什么会出现此错误以及我将如何摆脱此错误。
回答by CodeWizard
You are trying to cherry-pick
a merge. A merge is build up from at several parents. You have to supply the parent id to the merge.
您正在尝试cherry-pick
合并。合并是从几个父级建立的。您必须为合并提供父 ID。
You have to supply any of the followings:
您必须提供以下任何一项:
-m parent-number
/--mainline parent-number
Usually you cannot cherry-pick a merge because you do not know which side of the mergeshould be considered the mainline.
This option specifies the parent number (starting from 1) of the mainline and allows cherry-pick to replay the change relative to the specified parent.
-m parent-number
/--mainline parent-number
通常你不能挑选合并,因为你不知道合并的哪一侧应该被视为主线。
此选项指定主线的父级编号(从 1 开始),并允许cherry-pick 重播相对于指定父级的更改。
How to find out what are the commit parents?
如何找出什么是承诺父母?
Use the git show
command to view the commit parents and then you can choose the parent index or the SHA-1
使用该git show
命令查看提交父项,然后您可以选择父索引或 SHA-1
回答by VonC
This option specifies the parent number (starting from 1)
此选项指定父编号(从 1 开始)
Up until Git 2.13 (Q2 2017), that number could be 0! (which is incorrect)
直到 Git 2.13(2017 年第二季度),这个数字可能是 0!(这是不正确的)
See commit b16a991(15 Mar 2017) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
--in commit 9c96637, 17 Mar 2017)
请参阅Jeff King ( )提交的 b16a991(2017 年 3 月 15 日)。(由Junio C Hamano合并-- --在提交 9c96637 中,2017 年 3 月 17 日)peff
gitster
cherry-pick
: detect bogus arguments to--mainline
The cherry-pick and revert commands use
OPT_INTEGER()
to parse--mainline
. The stock parser is smart enough to reject non-numeric nonsense, but it doesn't know that parent counting starts at 1.Worse, the value "0" is indistinguishable from the unset case, so a user who assumes the counting is 0-based will get a confusing message:
$ git cherry-pick -m 0 $merge error: commit ... is a merge but no -m option was given.
The correct diagnosis is that "
-m 0
" does not refer to the first parent ("-m 1
" does).
cherry-pick
: 检测虚假参数--mainline
cherry-pick 和 revert 命令用于
OPT_INTEGER()
解析--mainline
. 股票解析器足够聪明,可以拒绝非数字废话,但它不知道父计数从 1 开始。更糟糕的是,值“0”与未设置的情况无法区分,因此假设计数是基于 0 的用户将收到令人困惑的消息:
$ git cherry-pick -m 0 $merge error: commit ... is a merge but no -m option was given.
正确的诊断是“
-m 0
”不指代第一个父代(“-m 1
”)。
回答by Vampire
Just as the Error suggest. You try to pick a merge commit, so you have tell git against which parent it should produce the diff that is then applied to the target.
正如错误所暗示的那样。您尝试选择合并提交,因此您已经告诉 git 应该针对哪个父级生成差异,然后将差异应用于目标。