Skip to content

Commit f72399b

Browse files
committed
Replace with preferred version
1 parent d7a5396 commit f72399b

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

content/git/merge.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ git merge --abort
1616

1717
# Merge conflicts
1818

19-
Source: <https://stackoverflow.com/questions/10697463/resolve-git-merge-conflicts-in-favor-of-their-changes-during-a-pull>
20-
2119
## Taking all of one side
2220

2321
**WARNING: This literally just takes all of one side it's not selective**.
2422

23+
Note: If you are unclear what `theirs` and `ours` refers to it's best to consult [the docs](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---theirs) before issuing any commands.
24+
25+
<details>
26+
27+
<summary>Old approach</summary>
28+
29+
Source: <https://stackoverflow.com/questions/10697463/resolve-git-merge-conflicts-in-favor-of-their-changes-during-a-pull>
30+
31+
I am keeping this version for reference but I no longer think it's a good approach because it is not exactly what I think of as take theirs.
32+
It will for example give errors for files that exist in `ours` but not in `theirs`, which kinda isn't what I want.
2533
If you are already in the merging state and have conflicts and want to take all of ours or theirs you can use one of following.
26-
If you are unclear what `theirs` and `ours` refers to it's best to consult [the docs](https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---theirs) and note it matters if you are rebasing (but this section I'm talking about merging).
2734

2835
```sh
2936
git checkout --theirs .
@@ -36,3 +43,11 @@ git checkout --ours .
3643
```
3744

3845
You can mark all the conflicts resolved after by using `git add .` or `git add -u` to only stage tracked files.
46+
47+
</details>
48+
49+
When issuing the checkout command specify if you want `ours` or `theirs`.
50+
51+
```sh
52+
git merge -X theirs <branch-name>
53+
```

0 commit comments

Comments
 (0)