[git] Git Cherry-Pick and Conflicts

There are two different git branches. In one the development is going in (Branch1).

In other branch some PoC work is going on (Branch2). Now, I want to cherry-pick the changes from Branch1 to Branch2, so that Branch2 is up to date.

Now, after cherry-picking 4 or 5 changes, I am getting some merge conflict and I am unable to proceed with further cherry-picks.

Do, I need to resolve all the conflicts before proceeding to next cherry -pick or Can I somehow postpone the conflict resolution till I cherry-pick all the changes (and resolve all conflicts together)?

Further, is it suggested to do cherry-pick or branch merge in this case?

This question is related to git cherry-pick git-cherry-pick

The answer is


Before proceeding:

  • Install a proper mergetool. On Linux, I strongly suggest you to use meld:

    sudo apt-get install meld
    
  • Configure your mergetool:

    git config --global merge.tool meld
    

Then, iterate in the following way:

git cherry-pick ....
git mergetool
git cherry-pick --continue

Also, to complete what @claudio said, when cherry-picking you can also use a merging strategy.

So you could something like this git cherry-pick --strategy=recursive -X theirs commit or git cherry-pick --strategy=recursive -X ours commit


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to cherry-pick

Git Cherry-Pick and Conflicts What does cherry-picking a commit with Git mean? git cherry-pick says "...38c74d is a merge but no -m option was given" How to git-cherry-pick only changes to certain files? How to cherry pick from 1 branch to another Is it possible to cherry-pick a commit from another git repository? Remove specific commit How to cherry-pick multiple commits Git Cherry-pick vs Merge Workflow

Examples related to git-cherry-pick

Git Cherry-Pick and Conflicts Abort a git cherry-pick? What does cherry-picking a commit with Git mean? Merge up to a specific commit How to cherry pick from 1 branch to another How to cherry pick a range of commits and merge into another branch? Partly cherry-picking a commit with Git How can I selectively merge or pick changes from another branch in Git?