Skip to content

[doc] Add new page on merge conflicts - #2237

Open
jvns wants to merge 7 commits into
gitgitgadget:masterfrom
jvns:merge-conflicts
Open

jvns wants to merge 7 commits into
gitgitgadget:masterfrom
jvns:merge-conflicts

Conversation

@jvns

@jvns jvns commented Sep 23, 2026

Copy link
Copy Markdown

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.

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. Those issues I'm aiming to solve in the first commit message.

Some things I'm still considering:

  • I wrote that git commit does the same thing as git merge --continue during a git merge , but I'm not sure if that's always true.
  • Not 100% sure that the explanation of diff3 vs zdiff3 is correct
  • Right now we're listing git merge, git revert, git rebase, git cherry-pick, and git pull as commands that can cause merge conflicts. I believe that git apply and git am can also result in conflicts when applying a patch, though it's a bit complicated because applying a patch is a different operation than doing a 3-way merge and the tools available for dealing with it are a different. My thought right now is to avoid the issue of applying patches for now (because it's a whole can of worms) and instead just try to not imply that this is necessarily an exhaustive list. Also if/when the git rebase --squash changes land, then we'd need to add git history to this list.
  • Instead of creating a new page, I considered using an include to have a "handling merge conflicts" in git rebase, git merge, etc. Merge conflict resolution is complex and it's very useful to be able to include examples: this version ended up at ~300 lines and I think that's too big of an include, especially for short man pages like cherry-pick
  • Explaining what "ours" and "theirs" mean was one of the hardest parts of writing this. From polling Git users in one of my many informal Mastodon polls about Git, my understanding is that Git users are actually relatively unlikely to actually reason about what "ours" and "theirs" mean when dealing with a merge conflict, and that most people prefer to get more context instead, for example by using a mergetool or by using diff3 or zdiff3. I heard a lot of "I can never remember which is which I so I don't even try". So I put the information about what "ours" and "theirs" mean relatively far down the page (with some cross-references), so that it's easily available but not the main focus.
  • I removed a couple of mentions of the various _HEAD references. It's hard for me to know exactly where they belong because I personally have never used MERGE_HEAD, REBASE_HEAD, ORIG_HEAD, CHERRY_PICK_HEAD etc, and I don't know how they're meant to be used. From some quick unscientific polling (at https://social.jvns.ca/@b0rk/117320011885941855), it seems like most Git users have never used them either (and folks who do use a *_HEAD reference mainly seem to use FETCH_HEAD which isn't relevant here), so from that perspective it seems important to avoid emphasizing them too much. The git revert man page doesn't mention REVERT_HEAD and git rebase only mentions REBASE_HEAD in passing. Of course they're all explained in gitrevisions(7) which might be the best place for them.
  • I'm still not sure what the SYNOPSIS section is for in a "guide" man page which is not about a specific Git command (what is the user intended to use it for?). I tried to leave it out but the CI said it was required.

Thanks to Lobo, Adam Svahn, Louis Vanier, David Turner, Ben Zanin, Salih, and about 10 others who gave feedback on both the original git merge man page, as well as the proposed improvements.

CC: ps@pks.im

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

There is an issue in commit 7dee697:
[doc] Add new gitmergeconflicts man page

  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

There is an issue in commit 3a9e01d:
[doc] git-merge: link to new merge conflicts guide

  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

There is an issue in commit c96ce90:
[doc] git-rebase: link to new merge conflicts guide

  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

There are issues in commit a340474:
[doc] git-revert: link to new merge conflicts guide

  • Commit checks stopped - the message is too short
  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

There is an issue in commit 67302e7:
[doc] git-cherry-pick: link to new merge conflicts guide

  • Commit not signed off

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

There are issues in commit 241bf3e:
[doc] git-pull: link to new merge conflicts guide

  • Commit checks stopped - the message is too short
  • Commit not signed off

@jvns jvns changed the title Merge conflicts [doc] Add new page on merge conflicts Sep 23, 2026
@jvns
jvns force-pushed the merge-conflicts branch 3 times, most recently from 9058e0a to 420858b Compare September 23, 2026 15:44
@jvns

jvns commented Sep 23, 2026

Copy link
Copy Markdown
Author

The check_whitespace job is failing because of merge conflict markers, but the reason there are merge conflict markers is that we're documenting how to handle merge conflicts. Not sure what to do about that.

(edit: I think it's in .gitattributes)

@dscho

dscho commented Sep 23, 2026

Copy link
Copy Markdown
Member

The check_whitespace job is failing because of merge conflict markers, but the reason there are merge conflict markers is that we're documenting how to handle merge conflicts.

Yep: see e.g. https://github.com/git/git/blob/v2.55.0/.gitattributes#L16

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.

Co-Authored-By: Marie Claire LeBlanc Flanagan
Signed-off-by: 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>
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>
Signed-off-by: Julia Evans <julia@jvns.ca>
Remove the discussion of merge conflicts and replace it with a link to
the guide.

Signed-off-by: Julia Evans <julia@jvns.ca>
Signed-off-by: Julia Evans <julia@jvns.ca>
Signed-off-by: Julia Evans <julia@jvns.ca>
@jvns

jvns commented Sep 23, 2026

Copy link
Copy Markdown
Author

Not sure what's going on with the debian-12 test failure but I'm planning to ignore it for now.

@dscho

dscho commented Sep 23, 2026

Copy link
Copy Markdown
Member

Not sure what's going on with the debian-12 test failure but I'm planning to ignore it for now.

@jvns see here: #2236. You can safely ignore it.

@jvns

jvns commented Sep 23, 2026

Copy link
Copy Markdown
Author

thanks, appreciate your work on testing!

@jvns

jvns commented Sep 23, 2026

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Sep 23, 2026

Copy link
Copy Markdown

Preview email sent as pull.2237.git.1790185498.gitgitgadget@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants