gitcommitgit-mergemerge-conflict-resolutioncherry-pick

Git - Cherry picking with ours/theirs strategy


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.


Solution

  • 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=ours HASH1 HASH2 HASH3 -n