Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ammend not allowed after resolving cherry-pick conflicts

Tags:

git

I cherry-picked a commit and resolved the conflicts, added them, now when I try to do git amend it fails with below message.

fatal: You are in the middle of a cherry-pick -- cannot amend.

Why does git gives this message, is there a way to tell it things are fine?

like image 474
garg10may Avatar asked Mar 20 '18 08:03

garg10may


People also ask

How do you continue cherry pick after resolving conflict?

cherry-pick effectively applies the changes from commit A onto the working tree and makes a commit. This means if you get any conflicts during cherry-pick ing you need to commit after resolving them to finish the cherry-pick . EDIT Edward noted that this is only true when you are cherry-pick ing a single commit.

How do I undo cherry pick changes in git?

A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit. Stash your current changes so you can reapply them after resetting the commit.

How do I exit git cherry pick continue?

Try also with '--quit' option, which allows you to abort the current operation and further clear the sequencer state. --quit Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick or revert.


2 Answers

I manually removed .git/CHERRY_PICK_HEAD now git doesn't know I did a cherry-pick, so amend works like it was a normal commit amend.

cherry-pick --continue adds a new commit message and would need to rebase which is a hassle.

like image 123
garg10may Avatar answered Nov 01 '22 16:11

garg10may


It seems that you did a cherry-pick before, which failed due to conflicts. Thus, git thinks you're still in the middle of the cherry pick, since it expects you to fix conflicts, add conflicted files and run git cherry-pick --continue.

Your options here are to run git cherry-pick --abort which will abort the cherry pick, i.e. return the conflicted files to their previous state, possible losing changes, or to run git cherry-pick --continue, which will continue the cherry pick. When you do not remember when and what you did with the cherry-pick, this is probably the better option, althoough you should watch your repository closely before and after the --continue command.

Both commands will get you out of the cherry-pick state and allow you to perform the amend.

like image 41
kowsky Avatar answered Nov 01 '22 16:11

kowsky