Git - Cherry picking with ours/theirs strategy

Sazzad Hissain Khan picture Sazzad Hissain Khan · Aug 10, 2017 · Viewed 9.2k times · Source

I wonder if there is any way of cherry picking with ours/theirs strategy. On other words, I want to cherry pick multiple commits from dev branch into main branch with below commands,

git cherry-pick HASH1 HASH2 HASH3 -n

This command is supposed to take all referred commits and prepare unstaged changes if no conflicts. However, if conflicts, I need to resolve and continue cherry-picking. For all conflicts, my intention is to pick whatever in the dev (which means, --strategy-option = ours).

Is there any way to provide such option while cherry-picking.

Answer

VonC picture VonC · Aug 10, 2017

The git cherry-pick command does have the --strategy and --strategy-option=<option> options.

They are passed through to the merge strategies.

So, in your case:

git cherry-pick --strategy-option=ours HASH1 HASH2 HASH3 -n