'Fatal: cherry-pick failed' with Git

xan picture xan · May 8, 2013 · Viewed 44.2k times · Source

I was working on a branch X. I made a commit and pushed it.

Then I wanted to cherry-pick it to branch Y. But due to some unmerged files present, I got the following message:

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.

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.

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.

EDIT #1

I edited the file mod/assign/locallib.php

On doing git status, I get:

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

Answer

pktangyue picture pktangyue · May 9, 2013

Since you have already edited the conflict file, you just need

git add mod/assign/locallib.php

then

git cherry-pick --continue