To resolve merge conflicts with master so that your changes override the conflicting changes from master, follow these steps:
1. Fetch and merge master
git fetch origin
git merge origin/master
If there are conflicts, Git will pause and mark the conflicting files.
What is the difference between git fetch and git pull?
git fetch downloads objects/refs from another repository (or remote) but doesn't merge them into your working directory. git pull does both: it fetches and then merges.
2. Overwrite conflicts with your version
For each conflicted file:
git checkout --ours <file>
--ours= your branch (i.e., your changes overridemaster)
Repeat this for all conflicted files or run:
git diff --name-only --diff-filter=U | xargs git checkout --ours
3. Mark conflicts resolved
git add .
4. Complete the merge
git commit
Alternative: Rebase with your changes overriding master
git rebase origin/master
Then during each conflict:
git checkout --ours <file>
git add <file>
git rebase --continue
Warning: This strategy discards all changes made in master for the conflicted files, so use it only when you're sure your changes must prevail.