Git 的“致命:樱桃选择失败”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16443501/
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
'Fatal: cherry-pick failed' with Git
提问by xan
I was working on a branch X
. I made a commit and pushed it.
我在一个分支上工作X
。我提交并推送了它。
Then I wanted to cherry-pick
it to branch Y
. But due to some unmerged files present, I got the following message:
然后我想把cherry-pick
它分支Y
。但是由于存在一些未合并的文件,我收到以下消息:
error: 'cherry-pick' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: cherry-pick failed
Now, I just want to delete my branch Y
, then re-create the branch Y
and then want to manually edit the file where I was trying to cherry-pick.
现在,我只想删除我的分支Y
,然后重新创建分支Y
,然后想要手动编辑我试图挑选的文件。
Currently, I'm unable to delete the branch as it is my working branch.
I cannot checkout
any other branch. I'm getting the following error on trying to change the branch.
目前,我无法删除该分支,因为它是我的工作分支。我不能在checkout
任何其他分支。尝试更改分支时出现以下错误。
mod/assign/locallib.php: needs merge
error: you need to resolve your current index first
I just need to delete the branch Y
, without losing anything on branch X
.
我只需要删除分支Y
,而不会丢失分支上的任何内容X
。
EDIT #1
编辑#1
I edited the file mod/assign/locallib.php
我编辑了文件 mod/assign/locallib.php
On doing git status
, I get:
在做git status
,我得到:
# On branch MDL-38267_24
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: mod/assign/locallib.php
#
What file should I add in git add ..
?
我应该添加什么文件git add ..
?
采纳答案by pktangyue
Since you have already edited the conflict file, you just need
由于您已经编辑了冲突文件,您只需要
git add mod/assign/locallib.php
then
然后
git cherry-pick --continue
回答by Schleis
You attempted to do a merge (via either git merge
or git pull
) and have files that have conflicts that are not resolved. If you do git status
, you will likely see file(s) listed as being 'changed by both'. You need to take care of this before you do anything else.
您尝试进行合并(通过git merge
或git pull
),并且有未解决冲突的文件。如果您这样做git status
,您可能会看到文件被列为“被双方更改”。在做任何其他事情之前,您需要注意这一点。
Do git mergetool
and it will bring up the files one at a time. Fix the file so that the conflicts are resolved and then you should be able to proceed.
这样做git mergetool
,它会一次一个地调出文件。修复文件以便解决冲突,然后您应该能够继续。