From b244c00a4e2e64cdf49bf7e90ed360eada9ca05c Mon Sep 17 00:00:00 2001 From: Kai Dalgleish Date: Tue, 14 Nov 2017 11:36:22 -0800 Subject: [PATCH] Add Note About --ours and --theirs (#133) * add note about --ours and --theirs * correct error message, add more detail on ours/theirs --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 339c932..08dee03 100644 --- a/README.md +++ b/README.md @@ -825,7 +825,7 @@ Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - modified: README.md + both modified: README.md ``` In this example, `README.md` has conflicts. Open that file and look for the following: @@ -840,7 +840,16 @@ In this example, `README.md` has conflicts. Open that file and look for the foll You will need to resolve the differences between the code that was added in your new commit (in the example, everything from the middle line to `new-commit`) and your `HEAD`. -Sometimes these merges are complicated and you should use a visual diff editor: +If you want to keep one branch's version of the code, you can use `--ours` or `--theirs`: + +```sh +(master*)$ git checkout --ours README.md +``` + +- When *merging*, use `--ours` to keep changes from the local branch, or `--theirs` to keep changes from the other branch. +- When *rebasing*, use `--theirs` to keep changes from the local branch, or `--ours` to keep changes from the other branch. For an explanation of this swap, see [this note in the git documentation](https://git-scm.com/docs/git-rebase#git-rebase---merge). + +If the merges are more complicated, you can use a visual diff editor: ```sh (master*)$ git mergetool -t opendiff