27

我在一个分支上工作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 ..

4

2 回答 2

20

由于您已经编辑了冲突文件,您只需要

git add mod/assign/locallib.php

然后

git cherry-pick --continue
于 2013-05-09T02:41:42.763 回答
2

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.

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.

于 2013-05-08T14:45:54.770 回答