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.
Points to remember git cherry-pick <commit-hash> to cherry-pick a commit from another branch. git cherry-pick -n <commit-hash> to cherry-pick the commit but it won't commit the changes. It will only stage all the changes. git cherry-pick —continue or git cherry-pick —abort when you face conflicts while cherry-picking.
In order to resolve the conflict use TortoiseGit → Resolve... and then right click on the conflicted file and choose one of Resolved (the current version of the file which is in the working tree will be used), Resolve conflict using 'mine' (the version of the file of your HEAD will be used), and Resolve conflict using ...
The most commonly used strategies are Fast Forward Merge and Recursive Merge. In this most commonly used merge strategy, history is just one straight line. When you create a branch, make some commits in that branch, the time you're ready to merge, there is no new merge on the master.
The 'ours' in Git is referring to the original working branch which has authoritative/canonical part of git history. The 'theirs' refers to the version that holds the work in order to be rebased (changes to be replayed onto the current branch).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With