10

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.

1 Answer 1

12

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.

6
  • 2
    no this does not help. As stated above, I excatly did this, but it lead to the translated error message. Even though git status says that there are no unstaged changes.
    – benni
    Feb 12, 2016 at 13:14
  • Did you commit the modified file ? Please post output of git status
    – SnehalK
    Feb 12, 2016 at 14:01
  • 2
    no, I did not commit, as the changes should be all done in one commit. (see above). The cherry-pick command says, that this should be possible.
    – benni
    Feb 12, 2016 at 14:43
  • 1
    @benni : I believe you have to commit the changes and then continue with git cherry pick, however you don't have to push them to repository. Changes should be added to the commit object only after "git add". once you are done with successful "git cherry-pick --continue" , then push them all at once.
    – SnehalK
    Feb 15, 2016 at 6:41
  • "git add", "git stash ...", "git cherry-pick --continue", then pop your stash. That worked for me.
    – clinux
    Oct 11, 2017 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.