Why would one use "git merge -s ours"?
Another reason is when you have a branch that is very out of sync with your active branch, and you wish to update the old one with the active one, but possible merge conflicts prevent this from being done easily with a normal merge.
For example, my use case was:
You have a master and dev branch, and for some reason, you have not updated your master branch in weeks, and your attempting to merge your dev branch into master now results in merge conflicts. What you may want to do is overwrite your master branch with the current state of your dev branch, so bring them both in sync.
What you can do in this case is as follows, using steps which have outlined by another SO user in another SO answer here. But please see my warning note below.
git checkout dev
git merge -s ours master
git checkout master
git merge dev
Worth a quick note: At the end of it, my master was up to date with my dev, but dev showed 4 commits to be pushed to the remote, which is strange. There should be 0 to push, as I just wanted to update master. Nevertheless, the code seemed fine. Just worth noting, as I had never used git merge -s ours
myself before this so im not 100% on its usage.
I also found another answer using ours
which could be useful to people: https://stackoverflow.com/a/13307342/339803
One use is to "skip" a commit made on a maintenance branch that isn't intended to go back into your main/trunk branch of development. See this previous question for an example: git - skipping specific commits when merging