Why does git cherry-pick not continue?

benni picture benni · Feb 12, 2016 · Viewed 7.1k times · Source

I am trying to cherry-pick changes from two different working brachnes to each other namely I want to cherry-pick the last 5 commits from branch linear to branch diagonal.

git cherry-pick -n -x linear~6..linear

As expected there are some merging conflicts for the first cherry-picked commit. I figure them out e.g. with git status, resolve them and update the index with git add. Now I want to continue with the rest but

git cherry-pick --continue`

leads to (sorry it is translated, english error message may be slightly different):

error: Your local changes will be overwritten by "cherry-pick".
Note: Stash your changes by using "stash" in order to continue.
fatal: "cherry-pick" failed.

What did I do wrong? How do I resolve conflicts but still commit a cherry-pick from several commits in only one commit? This is important for me as several of these commits will be undone by following commits.


This might be a duplicate of "How to do git cherry-pick --continue in SourceTree?" but I do not see my question answered there.

Answer

SnehalK picture SnehalK · Feb 12, 2016

Since you have already fixed the conflict file, you need to add it first to continue with git-cherry pick.

git add <modified file-name>
git commit -m "committing changes for file"
git cherry-pick --continue

Hope it will help.