To resolve merge conflicts with master
so that your changes override the conflicting changes from master
, follow these steps:
1. Fetch and merge master
1 2 |
|
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:
1 |
|
--ours
= your branch (i.e., your changes overridemaster
)
Repeat this for all conflicted files or run:
1 |
|
3. Mark conflicts resolved
1 |
|
4. Complete the merge
1 |
|
Alternative: Rebase with your changes overriding master
1 |
|
Then during each conflict:
1 2 3 |
|
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.