Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git cherry-pick not continue?

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.

like image 968
benni Avatar asked Feb 12 '16 11:02

benni


People also ask

How do you do cherry-pick on continue?

If you look at the console, "fix conflicts and run "git cherry-pick --continue." When fixing conflicts the normal way (without the cherry-pick), the console will mention to commit (after the conflicts have been fixed). As such, even with a single cherry-pick, I think that git cherry-pick --continue is the way to go.

Why is my cherry-pick empty?

If a commit being cherry picked duplicates a commit already in the current history, it will become empty. By default these redundant commits cause cherry-pick to stop so the user can examine the commit. This option overrides that behavior and creates an empty commit object. Implies --allow-empty .

How do you fix cherry-pick conflict?

One possible way to avoid these cherry-pick conflicts is by doing the cherry-picking in the order of oldest commit to latest commit, i.e. based on commit date.

Is it possible to cherry-pick multiple commits?

Cherry-Picking Multiple Commits Instead, it's possible to provide multiple commits, or even a range, as arguments for the command. The result of the command above would be two new commits with the same changes and content of the original commits from new.


1 Answers

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.

like image 184
SnehalK Avatar answered Sep 19 '22 10:09

SnehalK