Play video

What are Git Cherry Pick merge conflicts?

Cherry pick applies the changes introduced by the cherry picked commit onto the current branch. If changes introduced by the picked commit conflict with changes to those files on the current branch, you will see a merge conflict.

Merge conflicts can happen when a commit introduced after the branch split made changes OR if there are unstaged changes in your local workspace that conflict with the cherry picked commit.

On paper, merge conflicts can be confusing, but I recommend watching my video on how to fix them for a visual reference.

How to fix a Git Cherry Pick merge conflict

Get the unique identifier of the commit you want to pick

git log <branch-name> --oneline

Use cherry-pick to grab that commit by specifying it’s identifier

git cherry-pick <commit-hash>

When cherry-pick fails with a merge conflict note the file(s) that failed the merge. Open each of the failed files in a text editor of your choice and manually resolve the conflicts. After saving the files, stage them:

git add <file(s)-that-failed-merge>

Continue the cherry-pick operation

git cherry-pick continue

Git will kick you into your default text editor to specify a commit message for the new commit. Add a commit message and save the file (if you’re default editor is vim the command to save & quit is ESQ :wq)

Done!

How to cancel a Git Cherry Pick?

If you run the cherry-pick command and find yourself with more merge conflicts than you bargained for (or just want to abort the cherry pick operation), simply run:

git cherry-pick --abort