force git to accept cherry-pick's changes

Jiang picture Jiang · Jan 10, 2014 · Viewed 34.5k times · Source

I did cherry-pick from a gerrit review in my branch. In gerrit code review, I have two patch sets and I cherry-picked patch one before, so now I want to do the second patch set, but there are conflicts, how can I force git to accept all changes? Thanks!

Answer

CodeManX picture CodeManX · Sep 9, 2015

You can tell it to always prefer the changes of the commit you are cherry-picking:

git cherry-pick commitish --strategy-option theirs

commitish can be a SHA-1 hash of a commit, or a branch-name for the lastest commit of that branch, branch-name~1 for the commit before that etc.

If you want to do the reverse, use:

git cherry-pick commitish --strategy-option ours

The shorthand for --strategy-option is -X (uppercased X).

PS: What is the commit-ish, tree-ish?