Is this possible in SourceTree?
No, it is not directly possible, because a merge --ours
is not supported in Sourcetree.
(I have tested it with the latest 2.1.11.0, with Git 2.14.1 embedded, Sept. 2017).
See SRCTREEWIN-1237
(... from 2013!)
I need to use the ours strategy i.e. merge myBranch into master, discarding any changes on myBranch
git merge -s ours myBranch
This is still not available when merging two branches:
As mentioned in this article, you would need to define a custom action:
That will allow you to emulate the merge --ours
step of the following sequence
git checkout feature-01
git merge --strategy=ours master
git checkout master
git merge feature-01
The checkout
and simple merge
are supported in SourceTree. The custom action allows you to make the merge --ours
step.
And then, master
content will be replaced by feature-01
content.
Entirely from SourceTree alone.
For mercurial, following "Replace the content of a hg branch
", you would need to create a custom action (as illustrated above), for the command hg branch -f
(the -f
option is not available in the normal branch
dialog)