Thread View: linux.kernel.git
7 messages
7 total messages
Started by "Julia Evans via GitGitGadget"
Mon, 26 Oct 2026 12:39
[PATCH v5 0/6] [doc] Add new page on merge conflicts
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:39
Date: Mon, 26 Oct 2026 12:39
160 lines
18089 bytes
18089 bytes
Handling merge conflicts is difficult, and currently Git's guidance on merge
conflicts isn't giving users the information they need to navigate the
process. As usual, the process I used to write this was to collect comments
from Git users on the existing documentation, and then address those issues.
I listed the specific issues we're aiming to solve in the first commit
message in the series.
This patch series introduces a new manual page, gitmergeconflicts, which
explains the process of explaining a merge conflict with examples. It also
links to that new page from the commands which can cause merge conflicts,
instead of trying to reexplain the process every time.
Changed in v2:
* Explain what a merge conflict is (thanks to Junio & Ben)
* rewrite the "ours" vs "theirs" section (thanks to Patrick for the
comments)
* add git log --merge (thanks to Ben)
* Leave most of the content of git cherry-pick as-is, to make this patch
set smaller (thanks to Junio)
* remove the SYNOPSIS since hopefully that won't be required anymore by the
time this is merged
* Fix a typo in git revert (s/reverted conflict/reverted commit/)
* 's/the the/the/' (thanks to Patrick)
* s/[doc] Thing/doc: thing/ in commit messages (thanks to Tuomas)'
* squash the commit fixing the linter error (thanks to Junio)
* list reviewers in Reviewed-by
Changed in v3:
Thanks to all the comments from Junio.
* Add signoff from Marie
* In "For example, here's a merge conflict where both sides edited a list
of", add a little more detail about how to interpret the merge conflict
* When we introduce a merge mention "semantic merge conflicts"
* Say "... and any other command that does a merge" when listing commands
that can cause merge conflicts.
* Reviewed-by is not the right thing, use Helped-by
* Adjust phrasing in git revert and git cherry-pick man pages
* Reference the "ours" section in "git show :2:filename shows the "ours""
* "there's one file left with conflicts in it: fruits.py" isn't precise
enough, instead say "the conflicts in fruits.py haven't been marked as
resolved"
* Delete the explanation of zdiff3 and add a brief warning instead. Don't
be too prescriptive, we should tell people what the issue is (ambiguity)
instead of trying to impose our opinion.
* Explain ||||||| when we add diff3
* Fix example in "EXAMPLE OF RESOLVING A MERGE CONFLICT" to make it
consistent with the other examples
* Replace "configuration option" with "configuration variable"
* Mention --skip instead of saying "the most common ways", which is
ambiguous
* Add a pointer to the extended AUTO_MERGE sentence
Changed in v4:
changes to the content:
* use Junio's much better example for diff3
* clarify in the commit message why we're not mentioning git apply: to
avoid dealing with patches (thanks to Junio)
* adjust the wording around "multi-step operation like a rebase" (thanks to
Junio)
* Say "see git-config for more" in the description of zdiff3. Like Patrick
said the explanation of zdiff3 is not really satisfiying, but I don't
know how to write a satisfying explanation, and it's better to have a
short and obviously unsatisfying explanation than a long unsatisfying
one. Added a note in the commit message that perhaps this should be
improved in the future. (from Patrick's comment)
changes cleaning things up:
* add periods at the ends of various sentences in an attempt to be more
consistent (thanks to Junio & Patrick)
* Adjust the formatting around the [NOTE] to make the CI whitespace check
pass
* Replace a couple of instances of "code" with "lines" (thanks to Junio)
* Fix Ben's email address (thanks to Ben)
* Remove the double signoff (thanks to Ben).
* Make the cherry-pick commit message more accurate (thanks to Patrick)
Thanks to Lobo, Adam Svahn, Louis Vanier, David Turner, Ben Zanin, Salih,
and about 12 others who gave feedback on both the original git merge man
page, as well as the proposed improvements.
Julia Evans (6):
doc: add new gitmergeconflicts man page
doc: git-merge: link to new merge conflicts guide
doc: git-rebase: link to new merge conflicts guide
doc: git-revert: link to new merge conflicts guide
doc: git-cherry-pick: link to new merge conflicts guide
doc: git-pull: link to new merge conflicts guide
.gitattributes | 1 +
Documentation/Makefile | 1 +
Documentation/git-cherry-pick.adoc | 8 +-
Documentation/git-merge.adoc | 125 +---------
Documentation/git-pull.adoc | 3 +-
Documentation/git-rebase.adoc | 13 +-
Documentation/git-revert.adoc | 5 +
Documentation/gitmergeconflicts.adoc | 339 +++++++++++++++++++++++++++
Documentation/meson.build | 1 +
command-list.txt | 1 +
10 files changed, 366 insertions(+), 131 deletions(-)
create mode 100644 Documentation/gitmergeconflicts.adoc
base-commit: 3bc0341126508f78f5869cbfc0005e987efdf0c7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2237%2Fjvns%2Fmerge-conflicts-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2237/jvns/merge-conflicts-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/2237
Range-diff vs v4:
1: 486a77dbd7 ! 1: 8b526e2bd7 doc: add new gitmergeconflicts man page
@@ Commit message
there are other ways that merge conflicts can happen to avoid getting
into the difference between applying a patch and doing a 3-way merge.
- Things to potentially improve in future docs revisions:
-
- - The explanation of zdiff3 is unsatisfying. It would be good if we
- could have a clear example of a case where zdiff3 is helpful and a
- case where it's harmful, and if we could give a better sense for
- the reasons why users are actually choosing zdiff3 over diff3
- (or the reverse) in real life.
-
Co-Authored-By: Marie Claire LeBlanc Flanagan <hello@marieflanagan.com>
Helped-by: D. Ben Knoble <ben.knoble@gmail.com>
Helped-by: Patrick Steinhardt <ps@pks.im>
@@ Documentation/gitmergeconflicts.adoc (new)
+ "cherry",
+ "mango",
+||||||| 1c22e48
-+ "banana",
-+ "cherry",
++ "banana",
++ "cherry",
+ "mangoooo",
+=======
+ "banana",
@@ Documentation/gitmergeconflicts.adoc (new)
+----
+
+With this view, you can see that both sides fixed a spelling
-+mistake in "mango", and each removed one fruit to the list.
++mistake in "mango", and each removed one fruit from the list.
+This makes it more clear how to resolve the merge conflict: since one
+side removed `banana` and one side removed `cherry`, it would probably
+make sense to remove both from the list, like this:
2: 6862cb4f04 = 2: 3dc763a2a2 doc: git-merge: link to new merge conflicts guide
3: 2bd9850822 = 3: 02351af1b5 doc: git-rebase: link to new merge conflicts guide
4: 53083b48a3 = 4: 10f8947b68 doc: git-revert: link to new merge conflicts guide
5: 92cfdf260c = 5: e1fe1c4aa3 doc: git-cherry-pick: link to new merge conflicts guide
6: bbbf44aff1 = 6: 4f434f5acd doc: git-pull: link to new merge conflicts guide
--
gitgitgadget
[PATCH v5 1/6] doc: add new gitmergeconflicts man page
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:40
Date: Mon, 26 Oct 2026 12:40
445 lines
25993 bytes
25993 bytes
From: Julia Evans <julia@jvns.ca>
Introduce a new page, `gitmergeconflicts`, that explains the process of
handling a merge conflict in a way that addresses the following issues,
which came from feedback from Git users on the current explanation of
merge conflicts in the `git merge` man page:
- The process for resolving a merge conflict is only explained in the
`git merge` man page, even though there are several other commands
which can result in conflicts.
- Sometimes we use "ours" and "theirs" to refer to the two sides of
the merge conflicts and sometimes we use HEAD and MERGE_HEAD. It should
be consistent. Also the terms "ours" and "theirs" are not explained.
Similarly, it says "The part before the `=======` is typically your
side...", but doesn't explain what "typically" means.
- It introduces the merge format using an analogy to RCS, which very few
Git users have ever used.
- In "The only clean-ups you need are to reset the index file to the
`HEAD` commit to reverse 2. and to clean up working tree changes made
by 2. and 3.", it's not clear to users what "2" and "3" are supposed
to mean.
- It uses a cultural reference ("Conflict resolution is hard; let's go
shopping.") which is confusing or unfamiliar to some people. I think it
would be clearer for users to use a code example instead.
- It doesn't explain the difference between diff3 and zdiff3.
- It sometimes uses the term "area" and sometimes uses the term "hunk".
Also document the unified `--abort`, `--continue` workflow in one
place, since it's a really nice example of a place Git has a consistent
interface between similar commands.
Only discuss merge, rebase, cherry-pick, and revert for now even though
there are other ways that merge conflicts can happen to avoid getting
into the difference between applying a patch and doing a 3-way merge.
Co-Authored-By: Marie Claire LeBlanc Flanagan <hello@marieflanagan.com>
Helped-by: D. Ben Knoble <ben.knoble@gmail.com>
Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Marie Claire LeBlanc Flanagan <hello@marieflanagan.com>
Signed-off-by: Julia Evans <julia@jvns.ca>
---
.gitattributes | 1 +
Documentation/Makefile | 1 +
Documentation/gitmergeconflicts.adoc | 339 +++++++++++++++++++++++++++
Documentation/meson.build | 1 +
command-list.txt | 1 +
5 files changed, 343 insertions(+)
create mode 100644 Documentation/gitmergeconflicts.adoc
diff --git a/.gitattributes b/.gitattributes
index 26490ad60a..0a0fc950b1 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -14,6 +14,7 @@ CODE_OF_CONDUCT.md -whitespace
/t/oid-info/* text eol=lf
/Documentation/git-merge.adoc conflict-marker-size=32
/Documentation/git-merge-file.adoc conflict-marker-size=32
+/Documentation/gitmergeconflicts.adoc conflict-marker-size=32
/Documentation/gitk.adoc conflict-marker-size=32
/Documentation/user-manual.adoc conflict-marker-size=32
/t/t????-*.sh conflict-marker-size=32
diff --git a/Documentation/Makefile b/Documentation/Makefile
index f8dea4b395..bc49641dda 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -58,6 +58,7 @@ MAN7_TXT += gitdiffcore.adoc
MAN7_TXT += giteveryday.adoc
MAN7_TXT += gitfaq.adoc
MAN7_TXT += gitglossary.adoc
+MAN7_TXT += gitmergeconflicts.adoc
MAN7_TXT += gitpacking.adoc
MAN7_TXT += gitnamespaces.adoc
MAN7_TXT += gitremote-helpers.adoc
diff --git a/Documentation/gitmergeconflicts.adoc b/Documentation/gitmergeconflicts.adoc
new file mode 100644
index 0000000000..99052ab506
--- /dev/null
+++ b/Documentation/gitmergeconflicts.adoc
@@ -0,0 +1,339 @@
+gitmergeconflicts(7)
+====================
+
+NAME
+----
+gitmergeconflicts - Guide to handling merge conflicts
+
+DESCRIPTION
+-----------
+
+Merge conflicts can happen during a `git merge`, `git rebase`, `git
+cherry-pick`, `git pull`, `git revert`, or any other command that does
+a merge. All of those commands use the same merge algorithm, and the
+process for resolving a merge conflict is always very similar.
+
+There are 3 ways to handle a merge conflict:
+
+* Resolve the conflict. (see <<resolve,HOW TO RESOLVE A MERGE CONFLICT>>
+ below for details)
+* Stop the operation and return your branch to its original state
+ with the appropriate `--abort` command, for example `git merge --abort`
+ or `git rebase --abort`. See <<git_status,EXAMPLE: GIT STATUS OUTPUT>> below
+ for how to find the command to run.
+* Or (if you're in a multi-step operation like a rebase) skip the problematic
+ commit with the appropriate `--skip` command.
+
+WHAT IS A MERGE CONFLICT?
+-------------------------
+
+When Git merges two commits together, it looks at the changes that
+each side has made and combines those changes. For example, if one side
+edited lines 1-5 of `hello.py` and the other side edited lines 20-25 of
+the same file, then it can easily combine them since there's no overlap.
+
+But if both sides edited overlapping lines of the same file (for example
+one side edited lines 1-5 and the other edited lines 3-6), Git will
+not try to guess how to combine those changes. This is called a "merge
+conflict".
+
+When this happens, Git shows you both sides' edits and asks you to pick
+how to resolve them. It:
+
+* Stages all of the files which were successfully merged
+* For the files with conflicts, it marks them as conflicted, puts both
+ sides' edits in the file, and leaves <<markers, merge conflict markers>>
+ that you need to resolve.
+
+[NOTE]
+Even if Git successfully merges both sides with no conflicts, it's
+possible to end up with code that doesn't work. For example, this can
+happen if one side renames a function, and the other side adds a call to
+the old function. This is called a "semantic merge conflict".
+
+[[markers]]
+MERGE CONFLICT MARKERS
+----------------------
+
+When there's a merge conflict, Git will update the conflicted file
+to include merge conflict markers `<<<<<<<`, `=======`, and `>>>>>>>`.
+For example, here's a merge conflict where both sides edited a list of
+fruits in different ways -- one side has "cherry" and the other side
+has "banana":
+
+----
+FRUITS = [
+ "apple",
+<<<<<<< HEAD
+ "cherry",
+=======
+ "banana",
+>>>>>>> add-fruit
+ "mango",
+ "orange",
+]
+----
+
+The lines from one side of the merge conflict is between `<<<<<<<` and
+`=======`, and the lines from the other side is between `=======` and
+`>>>>>>>`. See <<ours,"OURS" AND "THEIRS">> below for a full explanation
+of which side is which.
+
+
+[[resolve]]
+HOW TO RESOLVE A MERGE CONFLICT
+-------------------------------
+
+The process for resolving a merge conflict is:
+
+1. Run `git status` to get a list of files with merge conflicts.
+2. For each one, find the conflict markers
+ (the `<<<<<<<`, `=======`, `>>>>>>>`) and edit the file to
+ fix the conflict.
+3. Run `git add FILENAME` for each file to mark the conflict as resolved.
+4. Run the appropriate `--continue` command to continue the operation
+ that was interrupted by the conflict, for example `git merge --continue`
+ or `git rebase --continue`. See <<git_status,EXAMPLE: GIT STATUS OUTPUT>>
+ below for how to find the command to run.
++
+Note: During a `git merge`, `git commit` and `git merge --continue` do
+the same thing.
+
+
+[[example]]
+EXAMPLE OF RESOLVING A MERGE CONFLICT
+-------------------------------------
+
+If you see this in your code during a merge conflict:
+
+----
+FRUITS = [
+ "apple",
+<<<<<<< HEAD
+ "cherry",
+=======
+ "banana",
+>>>>>>> add-fruit
+ "mango",
+ "orange",
+]
+----
+
+Then you might edit that part of the code like this,
+which includes the fruits from both sides of the conflict:
+
+----
+FRUITS = [
+ "apple",
+ "banana",
+ "cherry",
+ "mango",
+ "orange",
+]
+----
+
+
+[[tools]]
+TOOLS FOR HANDLING MERGE CONFLICTS
+----------------------------------
+
+Here are some ways to get extra context while handling a merge conflict:
+
+* There are many graphical "merge tools" for Git, which will normally
+ show you the different versions of the code side by side.
+ If you have a mergetool configured, `git mergetool` will launch it.
+ See also `merge.tool` in linkgit:git-config[1] for a list of
+ the mergetools Git supports.
+
+* You can set the configuration variable `merge.conflictstyle=diff3`.
+ See <<diff3,DIFF3>> below for more.
+
+* `git log --merge --patch <filename>` will list all commits which
+ caused the merge conflict for `<filename>`, and the diff
+ of how they changed the file.
+
+* Look at the original files. `git show :1:filename` shows the
+ common ancestor, `git show :2:filename` shows the "ours"
+ version, and `git show :3:filename` shows the "theirs"
+ version. See <<ours,"OURS" AND "THEIRS">> below for more on
+ "ours" and "theirs".
+
+Here are some ways to track your progress while handling a conflict:
+
+* Use `git status` to get a list of files with conflicts
+
+* Use `git diff --check` to make sure you haven't left any merge
+ conflict markers in a file by accident. It will print "leftover
+ conflict marker" if it finds any.
+
+* Use `git diff AUTO_MERGE` to show what changes you've made so far to
+ resolve the conflicts.
+ See <<automerge,EXAMPLE OF USING `AUTO_MERGE`>> below for more.
+
+[[git_status]]
+EXAMPLE: GIT STATUS OUTPUT
+--------------------------
+
+When you're in a merge conflict, you can find out what commands to run
+to handle the conflict by running `git status`.
+
+For example, this `git status` output tells you that:
+
+* `git rebase --abort` will safely bring your branch back to its
+ original state
+* you should run `git rebase --continue` when you're done resolving all
+ the conflicts
+* the conflicts in `fruits.py` haven't been marked as resolved
+
+----
+$ git status
+You are currently rebasing branch 'main' on '58a9fcc'.
+ (fix conflicts and then run "git rebase --continue")
+ (use "git rebase --skip" to skip this patch)
+ (use "git rebase --abort" to check out the original branch)
+
+Unmerged paths:
+ (use "git restore --staged <file>..." to unstage)
+ (use "git add <file>..." to mark resolution)
+ both modified: fruits.py
+----
+
+
+[[diff3]]
+DIFF3
+-----
+
+By default, Git doesn't include the original code when formatting
+a merge conflict. To include the original code, you can set the
+configuration option `merge.conflictstyle` to `diff3`.
+This extra context can make it much easier to understand what's
+happening in a merge conflict.
+
+Here's an example of what a merge conflict would look like when using
+`diff3`. There's an extra section (between `|||||||` and `=======`)
+with the original code.
+
+----
+FRUITS = [
+ "apple",
+<<<<<<< HEAD
+ "cherry",
+ "mango",
+||||||| 1c22e48
+ "banana",
+ "cherry",
+ "mangoooo",
+=======
+ "banana",
+ "mango",
+>>>>>>> add-fruit
+ "orange",
+]
+----
+
+With this view, you can see that both sides fixed a spelling
+mistake in "mango", and each removed one fruit from the list.
+This makes it more clear how to resolve the merge conflict: since one
+side removed `banana` and one side removed `cherry`, it would probably
+make sense to remove both from the list, like this:
+
+----
+FRUITS = [
+ "apple",
+ "mango",
+ "orange",
+]
+----
+
+[NOTE]
+`zdiff3` is an alternative to `diff3` that makes the merge conflict
+shorter by making it more ambiguous. See linkgit:git-config[1] for more.
+
+[[ours]]
+"OURS" AND "THEIRS"
+-------------------
+
+Sometimes during a merge conflict, Git will use the terms "ours" and
+"theirs" (or "us" and "them"). For example, `git status` might say that
+a file was `deleted by us`.
+
+"Ours" and "theirs" are both commits: "ours" is the current
+`HEAD` commit, and "theirs" is the other side being merged.
+
+The first part of a merge conflict (between `<<<<<<<` and `=======`) is
+from the "ours" side, and the second part (between `=======` and
+`>>>>>>>`) is from the "theirs" side.
+
+----
+FRUITS = [
+ "apple",
+<<<<<<< HEAD
+ "cherry", <- ours
+=======
+ "banana", <- theirs
+>>>>>>> add-fruit
+ "mango",
+ "orange",
+]
+----
+
+During a rebase, it can seem "upside down" because the "ours" commit is
+from the branch you're rebasing on (for instance `main` in `git rebase
+main`).
+
+These terms in Git all mean the same thing when dealing with a merge
+conflict:
+
+* "common ancestor" and "base". The files from this commit are "in stage 1".
+* "ours", "us", and `HEAD`. The files from this commit are "in stage 2".
+* "theirs", "them". The files from this commit are "in stage 3".
+
+If you're confused about what something like "deleted by us" means, it's
+often easiest to use some of the tools from
+<<tools,TOOLS FOR HANDLING MERGE CONFLICTS>> above to get more context.
+Finding the commit that deleted the file and seeing why is usually more
+helpful than trying to abstractly reason through what "us" means.
+
+[[automerge]]
+EXAMPLE OF USING `AUTO_MERGE`
+-----------------------------
+
+`git diff AUTO_MERGE` will show what changes you've made so far to
+resolve conflicts. `AUTO_MERGE` is a reference that Git creates during a
+merge. It contains the result of running the merge algorithm.
+
+For example, if we resolved the conflict by adding both "banana" and
+"cherry" in order, the diff would look like this:
+
+----
+ FRUITS = [
+ "apple",
+-<<<<<<< HEAD
+- "cherry",
+-=======
+ "banana",
+->>>>>>> add-fruit
++ "cherry",
+ "mango",
+ "orange",
+ ]
+----
+
+[NOTE]
+`AUTO_MERGE` is only set if you're using the default Git merge algorithm.
+
+
+SEE ALSO
+--------
+
+linkgit:git-revert[1]
+linkgit:git-merge[1]
+linkgit:git-rebase[1]
+linkgit:git-cherry-pick[1]
+linkgit:git-pull[1]
+linkgit:git-diff[1]
+
+GIT
+---
+
+Part of the linkgit:git[1] suite
diff --git a/Documentation/meson.build b/Documentation/meson.build
index f4854f802d..51647957e0 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -202,6 +202,7 @@ manpages = {
'gitfaq.adoc' : 7,
'gitglossary.adoc' : 7,
'gitpacking.adoc' : 7,
+ 'gitmergeconflicts.adoc' : 7,
'gitnamespaces.adoc' : 7,
'gitremote-helpers.adoc' : 7,
'gitrevisions.adoc' : 7,
diff --git a/command-list.txt b/command-list.txt
index 63ae2a67c9..f6e49c3c85 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -232,6 +232,7 @@ githooks userinterfaces
gitignore userinterfaces
gitk mainporcelain
gitmailmap userinterfaces
+gitmergeconflicts guide
gitmodules userinterfaces
gitnamespaces guide
gitprotocol-capabilities developerinterfaces
--
gitgitgadget
[PATCH v5 2/6] doc: git-merge: link to new merge conflicts guide
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:40
Date: Mon, 26 Oct 2026 12:40
162 lines
17128 bytes
17128 bytes
From: Julia Evans <julia@jvns.ca> All of the info about merge conflicts has been moved to the new guide Signed-off-by: Julia Evans <julia@jvns.ca> --- Documentation/git-merge.adoc | 125 +---------------------------------- 1 file changed, 3 insertions(+), 122 deletions(-) diff --git a/Documentation/git-merge.adoc b/Documentation/git-merge.adoc index a055384ad6..5b7b41cd10 100644 --- a/Documentation/git-merge.adoc +++ b/Documentation/git-merge.adoc @@ -49,7 +49,8 @@ a log message from the user describing the changes. Before the operation, A merge stops if there's a conflict that cannot be resolved automatically or if `--no-commit` was provided when initiating the merge. At that point you can run `git merge --abort` or `git merge ---continue`. +--continue`. See linkgit:gitmergeconflicts[7] +(or `git help mergeconflicts`) for a guide to handling merge conflicts. `git merge --abort` will abort the merge process and try to reconstruct the pre-merge state. However, if there were uncommitted changes when the @@ -231,127 +232,6 @@ git merge v1.2.3^0 git merge --ff-only v1.2.3 ---- -HOW CONFLICTS ARE PRESENTED ---------------------------- - -During a merge, the working tree files are updated to reflect the result -of the merge. Among the changes made to the common ancestor's version, -non-overlapping ones (that is, you changed an area of the file while the -other side left that area intact, or vice versa) are incorporated in the -final result verbatim. When both sides made changes to the same area, -however, Git cannot randomly pick one side over the other, and asks you to -resolve it by leaving what both sides did to that area. - -By default, Git uses the same style as the one used by the "merge" program -from the RCS suite to present such a conflicted hunk, like this: - ------------- -Here are lines that are either unchanged from the common -ancestor, or cleanly resolved because only one side changed, -or cleanly resolved because both sides changed the same way. -<<<<<<< yours:sample.txt -Conflict resolution is hard; -let's go shopping. -======= -Git makes conflict resolution easy. ->>>>>>> theirs:sample.txt -And here is another line that is cleanly resolved or unmodified. ------------- - -The area where a pair of conflicting changes happened is marked with markers -+<<<<<<<+, `=======`, and +>>>>>>>+. The part before the `=======` -is typically your side, and the part afterwards is typically their side. - -The default format does not show what the original said in the conflicting -area. You cannot tell how many lines are deleted and replaced with -Barbie's remark on your side. The only thing you can tell is that your -side wants to say it is hard and you'd prefer to go shopping, while the -other side wants to claim it is easy. - -An alternative style can be used by setting the `merge.conflictStyle` -configuration variable to either `diff3` or `zdiff3`. In `diff3` -style, the above conflict may look like this: - ------------- -Here are lines that are either unchanged from the common -ancestor, or cleanly resolved because only one side changed, -<<<<<<< yours:sample.txt -or cleanly resolved because both sides changed the same way. -Conflict resolution is hard; -let's go shopping. -||||||| base:sample.txt -or cleanly resolved because both sides changed identically. -Conflict resolution is hard. -======= -or cleanly resolved because both sides changed the same way. -Git makes conflict resolution easy. ->>>>>>> theirs:sample.txt -And here is another line that is cleanly resolved or unmodified. ------------- - -while in `zdiff3` style, it may look like this: - ------------- -Here are lines that are either unchanged from the common -ancestor, or cleanly resolved because only one side changed, -or cleanly resolved because both sides changed the same way. -<<<<<<< yours:sample.txt -Conflict resolution is hard; -let's go shopping. -||||||| base:sample.txt -or cleanly resolved because both sides changed identically. -Conflict resolution is hard. -======= -Git makes conflict resolution easy. ->>>>>>> theirs:sample.txt -And here is another line that is cleanly resolved or unmodified. ------------- - -In addition to the +<<<<<<<+, `=======`, and +>>>>>>>+ markers, it uses -another +|||||||+ marker that is followed by the original text. You can -tell that the original just stated a fact, and your side simply gave in to -that statement and gave up, while the other side tried to have a more -positive attitude. You can sometimes come up with a better resolution by -viewing the original. - - -HOW TO RESOLVE CONFLICTS ------------------------- - -After seeing a conflict, you can do two things: - - * Decide not to merge. The only clean-ups you need are to reset - the index file to the `HEAD` commit to reverse 2. and to clean - up working tree changes made by 2. and 3.; `git merge --abort` - can be used for this. - - * Resolve the conflicts. Git will mark the conflicts in - the working tree. Edit the files into shape and - `git add` them to the index. Use `git commit` or - `git merge --continue` to seal the deal. The latter command - checks whether there is a (interrupted) merge in progress - before calling `git commit`. - -You can work through the conflict with a number of tools: - - * Use a mergetool. `git mergetool` to launch a graphical - mergetool which will work through the merge with you. - - * Look at the diffs. `git diff` will show a three-way diff, - highlighting changes from both the `HEAD` and `MERGE_HEAD` - versions. `git diff AUTO_MERGE` will show what changes you've - made so far to resolve textual conflicts. - - * Look at the diffs from each branch. `git log --merge -p <path>` - will show diffs first for the `HEAD` version and then the - `MERGE_HEAD` version. - - * Look at the originals. `git show :1:filename` shows the - common ancestor, `git show :2:filename` shows the `HEAD` - version, and `git show :3:filename` shows the `MERGE_HEAD` - version. - - EXAMPLES -------- @@ -406,6 +286,7 @@ linkgit:git-reset[1], linkgit:git-diff[1], linkgit:git-ls-files[1], linkgit:git-add[1], linkgit:git-rm[1], linkgit:git-mergetool[1] +linkgit:gitmergeconflicts[7] GIT --- -- gitgitgadget
[PATCH v5 3/6] doc: git-rebase: link to new merge conflicts guide
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:40
Date: Mon, 26 Oct 2026 12:40
55 lines
12722 bytes
12722 bytes
From: Julia Evans <julia@jvns.ca>
Remove some of the detail about how to handle a merge conflict, since
it's explained in detail in the new guide, and there probably isn't
enough detail anyway.
Leave the steps since rebase is special and has a `--skip` option which
the other commands which cause merge conflicts don't have.
Signed-off-by: Julia Evans <julia@jvns.ca>
---
Documentation/git-rebase.adoc | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rebase.adoc b/Documentation/git-rebase.adoc
index f6c22d1598..da70aff498 100644
--- a/Documentation/git-rebase.adoc
+++ b/Documentation/git-rebase.adoc
@@ -46,10 +46,7 @@ If there is a merge conflict during this process, `git rebase` will stop at the
first problematic commit and leave conflict markers. If this happens, you can do
one of these things:
-1. Resolve the conflict. You can use `git diff` to find the markers (<<<<<<)
- and make edits to resolve the conflict. For each file you edit, you need to
- tell Git that the conflict has been resolved. You can mark the conflict as
- resolved with `git add <filename>`. After resolving all of the conflicts,
+1. Resolve the conflict. After resolving all of the conflicts,
you can continue the rebasing process with
git rebase --continue
@@ -62,6 +59,9 @@ one of these things:
git rebase --skip
+See linkgit:gitmergeconflicts[7] (or `git help mergeconflicts`)
+for a full guide to handling merge conflicts.
+
If you don't specify an `<upstream>` to rebase onto, the upstream configured in
`branch.<name>.remote` and `branch.<name>.merge` options will be used (see
linkgit:git-config[1] for details) and the `--fork-point` option is
@@ -1284,6 +1284,11 @@ include::includes/cmd-config-section-all.adoc[]
include::config/rebase.adoc[]
include::config/sequencer.adoc[]
+SEE ALSO
+--------
+
+linkgit:gitmergeconflicts[7]
+
GIT
---
Part of the linkgit:git[1] suite
--
gitgitgadget
[PATCH v5 4/6] doc: git-revert: link to new merge conflicts guide
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:40
Date: Mon, 26 Oct 2026 12:40
33 lines
11587 bytes
11587 bytes
From: Julia Evans <julia@jvns.ca> Signed-off-by: Julia Evans <julia@jvns.ca> --- Documentation/git-revert.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/git-revert.adoc b/Documentation/git-revert.adoc index ffba365e63..bb0f859f66 100644 --- a/Documentation/git-revert.adoc +++ b/Documentation/git-revert.adoc @@ -31,6 +31,10 @@ both will discard uncommitted changes in your working directory. See "Reset, restore and revert" in linkgit:git[1] for the differences between the three commands. +Reverting a commit may result in a merge conflict. +See linkgit:gitmergeconflicts[7] (or `git help mergeconflicts`) +for a guide to handling merge conflicts. + OPTIONS ------- <commit>...:: @@ -162,6 +166,7 @@ include::config/revert.adoc[] SEE ALSO -------- linkgit:git-cherry-pick[1] +linkgit:gitmergeconflicts[7] GIT --- -- gitgitgadget
[PATCH v5 5/6] doc: git-cherry-pick: link to new merge conflicts guide
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:40
Date: Mon, 26 Oct 2026 12:40
43 lines
12010 bytes
12010 bytes
From: Julia Evans <julia@jvns.ca>
Signed-off-by: Julia Evans <julia@jvns.ca>
---
Documentation/git-cherry-pick.adoc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-cherry-pick.adoc b/Documentation/git-cherry-pick.adoc
index f4cd8b9db7..069e434961 100644
--- a/Documentation/git-cherry-pick.adoc
+++ b/Documentation/git-cherry-pick.adoc
@@ -19,8 +19,7 @@ Given one or more existing commits, apply the change each one
introduces, recording a new commit for each. This requires your
working tree to be clean (no modifications from the HEAD commit).
-When it is not obvious how to apply a change, the following
-happens:
+When a merge conflict happens:
1. The current branch and `HEAD` pointer stay at the last commit
successfully made.
@@ -36,8 +35,8 @@ happens:
conflict markers `<<<<<<<` and `>>>>>>>`.
5. No other modifications are made.
-See linkgit:git-merge[1] for some hints on resolving such
-conflicts.
+See linkgit:gitmergeconflicts[7] (or `git help mergeconflicts`)
+for a guide to handling merge conflicts.
OPTIONS
-------
@@ -259,6 +258,7 @@ $ git cherry-pick -Xpatience topic^ <4>
SEE ALSO
--------
linkgit:git-revert[1]
+linkgit:gitmergeconflicts[7]
GIT
---
--
gitgitgadget
[PATCH v5 6/6] doc: git-pull: link to new merge conflicts guide
Author: "Julia Evans via GitGitGadget"
Date: Mon, 26 Oct 2026 12:40
Date: Mon, 26 Oct 2026 12:40
24 lines
11432 bytes
11432 bytes
From: Julia Evans <julia@jvns.ca> Signed-off-by: Julia Evans <julia@jvns.ca> --- Documentation/git-pull.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/git-pull.adoc b/Documentation/git-pull.adoc index 88f4fd3926..73f6d460bb 100644 --- a/Documentation/git-pull.adoc +++ b/Documentation/git-pull.adoc @@ -38,7 +38,8 @@ or `pull.ff` with your preferred behaviour. If there's a merge conflict during the merge or rebase that you don't want to handle, you can safely abort it with `git merge --abort` or -`git rebase --abort`. +`git rebase --abort`. See linkgit:gitmergeconflicts[7] +(or `git help mergeconflicts`) for a guide to handling merge conflicts. OPTIONS ------- -- gitgitgadget
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads