致命错误:Git中cherry-pick失败

30

我正在分支X上工作。我提交并推送了更改。

然后我想将其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

现在,我只想删除我的分支Y,然后重新创建分支Y并手动编辑我正在尝试挑选的文件。

目前,由于这是我的工作分支,我无法删除该分支。我不能checkout到任何其他分支。在尝试更改分支时,我会收到以下错误提示。

mod/assign/locallib.php: needs merge
error: you need to resolve your current index first

我只需要删除分支Y,而不会丢失分支X上的任何内容。

编辑#1

我编辑了文件mod/assign/locallib.php

执行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
#

git add .. 中我应该添加哪个文件?

2个回答

24

既然您已经编辑了冲突文件,您只需要

git add mod/assign/locallib.php

然后

git cherry-pick --continue

2
您尝试进行合并(通过git mergegit pull),但存在未解决的冲突文件。如果您执行git status,您可能会看到文件被标记为“changed by both”。在继续之前,您需要先处理这些冲突。
执行git mergetool,它会逐个显示文件。解决冲突后,您就可以继续进行了。请注意保留HTML标签。

请查看我对问题所做的修改。我的意思是我修改的文件和git status返回的文件是相同的。我该如何解决我遇到的问题? - xan
你需要解决冲突或将文件git reset为未冲突状态,具体取决于导致冲突的原因。 - Schleis

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接