I understand that the \"ours\" merge strategy (hear the quotes around merge?) actually does not use any commits from the other branch.
The \"ours\" strategy is
In short: common ancestor.
Whenever you do a merge, git
will find a common ancestor of the current branch and the branch to be merged. Then git
merges commits after the common ancestor from the other branch into current branch.
git merge -s ours
ignores any content from the other branch entirely. It's just creating a new common ancestor.
It changes the commit range to be merged for the future merges.
Here's a use case in the "Advanced Merging" chapter from the book Pro Git
For example, say you branched off a
release
branch and have done some work on it that you will want to merge back into yourmaster
branch at some point. In the meantime some bugfix onmaster
needs to be backported into yourrelease
branch. You can merge the bugfix branch into therelease
branch and alsomerge -s ours
the same branch into yourmaster
branch (even though the fix is already there) so when you later merge therelease
branch again, there are no conflicts from the bugfix.
In this example, git merge -s ours
is used to skip commits related to bugfix commits merged in release
branch.