A Merge Conflict Left in a Markdown Note Renders as a Heading
A merge conflict left in a Markdown note does not look like a conflict once it is rendered. Git's ======= separator is a valid heading underline, so the line above it turns into a large heading, and >>>>>>> opens seven nested block quotes. In every renderer we tested, including GitHub, the conflict came out as formatting.1
That matters to anyone who keeps a notes folder in git — on a desktop client, through a plugin, or with a working copy on a phone. A pull goes wrong, the note opens, and the reading view shows an odd second title and a word indented far to the right. Nothing on the screen says conflict. It reads as a styling glitch — and styling glitches get ignored.
Why two devices end up editing the same lines is covered in When Two Devices Edit the Same Note.2 That post calls a plain-text conflict a readable diff — and in the source, it is. This post starts where that one's merge case ends: the markers are already in the file, and the rendered view is hiding them.
The fix is to stop asking the reading view this particular question. Three checks, in order, answer it from the source: find every marker in the folder with grep, let git diff --check flag them before a commit, and on Git 2.56 or later stage with git add --resolved, which will not stage a file that still has them.
What a leftover conflict looks like in the reading view
Two branches, standing in for two devices, changed one line of a trip note, and git merge left both versions between three marker lines. Rendered, the note shows a second large title reading <<<<<<< HEAD Flight leaves at 9:15., then the other version as an ordinary line, then the word phone indented seven quote levels deep.1
The receipt is a real merge. A scratch repository on git 2.53.0 held a note that said Flight leaves at 8:00. One branch changed it to 9:15, a branch named phone changed it to 7:40 — and the merge stopped with a conflict.3 This is the file it left behind:
# Trip
<<<<<<< HEAD
Flight leaves at 9:15.
=======
Flight leaves at 7:40.
>>>>>>> phone
Pack the charger.
And this is what commonmark.js 0.31.2 made of it:
<h1>Trip</h1>
<h1><<<<<<< HEAD
Flight leaves at 9:15.</h1>
<p>Flight leaves at 7:40.</p>
<blockquote><blockquote><blockquote><blockquote><blockquote><blockquote><blockquote>
<p>phone</p>
</blockquote></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote>
<p>Pack the charger.</p>
The same structure came out of all seven configurations tested — markdown-it 14.3.3 in its commonmark and default presets, commonmark.js 0.31.2, marked 18.2.1, micromark 4.0.3 with and without its GFM extension, and GitHub's Markdown API in gfm mode.1
Two of the three markers are gone as text. The separator vanished into a heading underline. The branch marker became seven quote bars around one word.
Why Markdown reads the markers as formatting
Markdown has no idea what a merge conflict is. It sees ordinary lines and applies its block rules: a row of = characters under a paragraph is a heading underline, and a > at the start of a line opens a block quote. Git's markers satisfy both rules by accident — so a renderer formats them instead of showing them.
Git's documentation describes the markers plainly: "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."4 Each marker is seven characters long by default.5
The middle marker is the trouble. The CommonMark specification defines the underline of a setext heading — the older, underlined heading style — this way: "A setext heading underline is a sequence of = characters or a sequence of - characters, with no more than 3 spaces of indentation and any number of trailing spaces or tabs."6 Seven = characters qualify.
The spec then explains why the first marker ends up inside the heading: "A blank line is needed between a paragraph and a following setext heading, since otherwise the paragraph becomes part of the heading's content".6 Git writes no blank lines inside a conflict. So <<<<<<< HEAD and your version join into a single paragraph — and that paragraph becomes the heading.
The last marker is a stack of block-quote markers. The spec's basic case reads: "If a string of lines Ls constitute a sequence of blocks Bs, then the result of prepending a block quote marker to the beginning of each line in Ls is a block quote containing Bs."7 A marker may be a > with no space after it, so >>>>>>> phone is seven quotes deep — each inside the last.
None of this is a renderer bug. Each engine did what the standard says.
It does not always look like a marker
The large heading with <<<<<<< in it is only one shape. When one side of the conflict has two paragraphs, the heading holds clean text — and looks deliberate. Inside a bulleted list there is no heading at all. The seven nested quotes, though, appeared in every case and every configuration tested.1
Five conflicted notes, each produced by a real merge, went through the same renderers: all six local configurations, plus GitHub's API for the first three.13
| Note | What the reading view shows | Why |
|---|---|---|
| Trip — one line on each side | A large heading <<<<<<< HEAD Flight leaves at 9:15., their line as plain text, phone in seven nested quotes | No blank line, so the marker line joins the heading |
| Plan — your side has two paragraphs | <<<<<<< HEAD Day one: gallery. as a plain paragraph, then a large heading Dinner at eight. with no marker in it; seven quotes around phone | Only the paragraph directly above ======= becomes the heading |
| Groceries — conflict inside a bullet list | No heading. Bullets read milk <<<<<<< HEAD, bread ======= and oat milk; seven quotes around phone | Heading text cannot be a list item, so ======= stays list text |
| Trip, diff3 style | One heading holding <<<<<<< ours, your line, ||||||| base and the original line | The base section is just more paragraph text |
| Trip with Windows line endings | Same as the first row in all six local configurations | A carriage return before the line feed is part of the line ending |
The plan note is the dangerous one. A heading that says Dinner at eight. looks like something the author typed on purpose. Nothing in it points to a conflict; the stray marker text sits higher up, in an ordinary paragraph.
A heading that appears by accident also lands in the note's outline — the view Navigate a Long Note by Its Outline uses to move through a long note.8 Outline panes were not part of this test.
The list case is the honest counter-example. The specification says the lines of a setext heading "cannot be interpretable as a code fence, ATX heading, block quote, thematic break, list item, or HTML block."6 Inside a list, ======= is folded into the bullet above it — plain text, no heading.
The diff3 style is worth knowing because some people turn it on. Git's documentation says of the default style that it "does not show what the original said in the conflicting area."4 The diff3 style, which the receipt produced by asking git to re-create the conflict with --conflict=diff3, adds that original between ||||||| and ======= — and in the rendered note, the original is swallowed into the heading with everything else.
Step 1: find every marker in the folder with grep
Search the source for lines made of exactly seven <, |, = or > characters, then a space, a tab or the end of the line. That is, give or take one detail, the test git itself applies to decide whether a line is a conflict marker. It finds markers in any note — staged or not, conflict remembered or not.
From the top of the notes folder:
grep -rnE --include='*.md' '^(<{7}|[|]{7}|={7}|>{7})([[:space:]]|$)' .
On the five receipt notes it listed every marker line, including ||||||| base in the diff3 note and all three markers in the note with Windows line endings. The output names the file and line — enough to open each hit in a source view.3
The pattern mirrors git's own source. In merge-ll.c, the function that recognises a marker line accepts only =, >, < and |, requires the run to be exactly the marker size, and then checks if (!isspace((unsigned char)line[marker_size])).9 A carriage return counts as whitespace there — which is why the pattern ends in [[:space:]] rather than a plain space. The one detail: for < and >, git first demands a plain space after the run. The grep is a little looser there, so it can only list more lines than git would, never fewer.
That detail is not cosmetic. A simpler pattern that ended in ( |$) found only two of the three markers in the Windows-line-ending note. It missed ======= followed by a carriage return — the very line that turns the conflict into a heading.3 It also missed the diff3 ||||||| line. Why a note might have Windows line endings at all is the subject of Line Endings in Your Notes.10
Two limits. The pattern assumes the default marker length: git's conflict-marker-size attribute "controls the length of conflict markers left in the work tree file during a conflicted merge", and a repository can set it higher.5 The documentation's own example sets 32 for one file. If a notes repository sets a size, change the {7} to match.
And there is one false positive. A setext heading underlined with exactly seven = characters matches too — git's rule cannot tell it apart either. An underline of eight = did not match.3 Adding one more = to such an underline ends the confusion for both.
Inside a git repository, the same pattern runs against what was committed:
git grep -nE '^(<{7}|[|]{7}|={7}|>{7})([[:space:]]|$)' HEAD -- '*.md'
After a merge was committed with its markers still in place, that command listed all twelve marker lines in the four committed notes.3
Step 2: let git check before you commit
Run git diff --check before committing a resolved merge. It names every leftover marker by file and line and exits with a non-zero status. A plain git add and git commit do not check — in the receipt, they staged and committed four notes full of markers without a word.
Git's documentation states the option's job in one line: "Warn if changes introduce conflict markers or whitespace errors."11 In the receipt, after a plain git add of the four conflicted notes, git status showed all four as ordinary staged changes, and git commit exited 0. The markers were now history.3
The same staged changes, checked first, told a different story:
$ git diff --cached --check
plan.md:3: leftover conflict marker
plan.md:7: leftover conflict marker
plan.md:11: leftover conflict marker
trip.md:3: leftover conflict marker
trip.md:5: leftover conflict marker
trip.md:7: leftover conflict marker
That excerpt is shortened — the full run listed every marker in all four notes and exited with status 2.3 Without --cached, the check also works on unstaged changes while the conflict is still open. For a merge that was already committed, git diff --check HEAD~1 HEAD compares it with the commit before and exited 2 with the same list.3
To run the check on every commit, git ships a sample hook. Its documentation says only that "The default 'pre-commit' hook, when enabled, prevents the introduction of non-ASCII filenames and lines with trailing whitespace."12 It says nothing about markers. But the hook's last line is exec git diff-index --check --cached $against -- — the same check.13 Enabled with cp .git/hooks/pre-commit.sample .git/hooks/pre-commit, it refused the marker commit with exit 1.3
Read the caveats before enabling it in a notes repository. The hook refuses trailing whitespace — and two trailing spaces are Markdown's hard line break. A note using one was refused with exit 1.3 It also refused a new file named Tâche.md; the hook's own comments say to set hooks.allownonascii to true to allow such names.13 And git commit --no-verify skips the hook entirely; it exited 0 with the markers in place.3
Hooks are local and opt-in. Anything that runs a plain git add and git commit on a timer will commit whatever the file contains, as the receipt did.
Step 3: on Git 2.56, stage with git add --resolved
Git 2.56, released on 28 September 2026, added git add --resolved, which stages files after a conflict and refuses to stage any of them if one still contains markers. It is the closest thing git has to a guard at the staging step — but it only checks files git still considers unmerged.
The release notes describe it this way: "'git add' has been taught a new '--resolved' option to stage conflict-resolved paths, while leaving unrelated local changes unstaged. It scans the unmerged paths for leftover conflict markers and aborts if any are found."14
The manual is stricter about what "aborts" means: "Unmerged paths without conflict markers (including binary files and file deletions) are staged as resolved, while any path with leftover conflict markers causes the command to refuse to stage any files. Cannot be combined with -u or -A."15
One unresolved note blocks the whole batch.
In the source, the refusal reads the following paths still have conflict markers:, followed by the list.16
The gap is in the word unmerged. The loop in builtin/add.c skips every index entry that is not in a conflict stage, with if (!ce_stage(ce)) followed by continue;.16
Alex Georgiev, who built 2.56.0 from source to test the flag, put it in one line: "It only fires while git's index still thinks the path is unmerged."17 Once a note has been staged with a plain git add — or its conflict state reset — --resolved has nothing left to check.
Georgiev's summary is fair to the feature: "The core promise held up. The safety check around it had a gap I didn't expect."17 He also notes that “The flag's unit of "unrelated" is the file, not the line.”17 Read with the release note above, that means unrelated edits inside a resolved note are staged along with the resolution.
Git 2.56 is also new, and many machines run older versions — including the one behind this post's receipt, on 2.53.0, so --resolved was not run here. Its behaviour above comes from the manual, the release notes, the source and Georgiev's test.
Use it as the third check, never the only one.
Resolving the conflict inside the note
Commit or copy the folder first, then open each flagged note in a source or plain-text view rather than the reading view. Keep one version of the lines, or combine them, and delete the three marker lines — four in diff3 style. Then run the Step 1 grep again until it prints nothing.
In order:
- Back up. Commit the current state, or copy the folder, before editing several conflicted notes. A mistake is then one command away from undone.
- Open the source. A source view, a plain-text editor, or the line numbers from the grep output. The reading view is what hid the conflict.
- Choose. Keep your version, theirs, or a line of your own that combines them. Grep only finds markers; it cannot decide which flight time is right.
- Delete the markers. Remove
<<<<<<<,=======and>>>>>>>, plus|||||||and the base text in diff3 style. - Check. Run the Step 1 grep, then
git diff --check, then stage.
To take one side for a whole note, git can write it for you while the conflict is open. git checkout --theirs -- trip.md replaced the receipt's trip note with the phone version — markers gone. --ours keeps the other side.3 A Stack Overflow question asking for exactly that — take one side of a whole file — has 403,831 views.18
Note tools are starting to help with the source step. A pull request merged into obsidian-git — a community plugin with 12,308 stars on GitHub — on 19 September 2026 adds a conflict-resolution interface in the editor.19 Its author, ViscousPot, notes the limit plainly: "Note: the purple quote lines after a conflict are markdown reacting to the > in >>>>>>>. Pre-existing, and fixing it properly needs parser-level work, so I left it out."19
The same description adds: "Only shows in Live Preview. Source mode still shows the raw markers for manual edits."19 The source view, again, is where the conflict is visible as itself.
Common mistakes
Leftover markers usually survive one of five habits: fixing what the reading view shows instead of the source, searching with too narrow a pattern, skipping git's check, trusting --resolved with a note it never saw, and underlining a heading with exactly seven =. Each takes seconds to avoid — once you know it is there.
- Fixing the formatting instead of the conflict. Deleting the heading or the quote bars in a rich editor can remove
=======while leaving both versions of the line. Grep for markers after any edit. - A grep that ends in a plain space. It misses the carriage-return line in a note with Windows line endings and the diff3 base marker. End the pattern with
[[:space:]]and include|. - Committing with
--no-verifyout of habit. It skips the one hook that would have caught the markers. - Treating
--resolvedas a scan of the folder. It checks only files still in conflict. A note staged earlier, or a marker committed last week, passes it. - Underlining a heading with exactly seven
=. Git's rule and the grep both read it as a marker. Use eight, or a#heading.
Every one of them is invisible in the reading view.
What this test does not show
The renderers in this test are parsers and GitHub's API — not note apps. Obsidian's reading view and Live Preview, Typora and VS Code's preview were not rendered, so this post makes no claim about the heading in any of them. Each app uses its own engine and settings, and may differ.
The one in-app observation comes from the obsidian-git pull request above, which reports the nested quote lines in Obsidian's Live Preview.19
Whether that view also shows the large heading is not known from this test.
Checking your own app takes one minute: paste the trip note from the top of this post into a new note and switch to the reading view.
git add --resolved was not executed for this post, as noted above. The grep pattern assumes the default seven-character markers. The Stack Overflow figures were read on 22 November 2026 and will move: the question titled "Git conflict markers" has 307,693 views, and "Merge conflict marker encountered" has 71,292.18
Readers deciding whether to put notes in git at all will find the case for it in Version Control Is Having a Moment.20 Readers who hit a different kind of disappearing line — one Markdown reads as a link definition — will find it in Write "[Status]: draft" in a Markdown Note and the Line Disappears.21
Frequently Asked Questions
The questions below are phrased the way people search for this problem, several of them as titles of Stack Overflow questions. Each answer stands alone and assumes a notes folder kept in git. The commands are the ones run in the receipt behind this post, on git 2.53.0, except git add --resolved, which needs Git 2.56.
Why is there a heading with HEAD in my Markdown note?
A merge conflict was left in the note. Git's ======= separator is a valid setext heading underline, so the <<<<<<< HEAD line and your version under it render as one large heading. In every renderer tested, including GitHub, the other version showed as a plain line and >>>>>>> became seven nested quotes. Fix it in the source view.
Git conflict markers: what do <<<<<<<, ======= and >>>>>>> mean?
They mark one conflicting area. Lines between <<<<<<< and ======= are typically your side; lines between ======= and >>>>>>> are typically theirs. The word after each outer marker names the side, such as HEAD or a branch. In diff3 style, a ||||||| section between them shows the original text.
How do I find leftover merge conflict markers in my notes?
Search the source, not the reading view. From the notes folder, run grep -rnE --include='*.md' '^(<{7}|[|]{7}|={7}|>{7})([[:space:]]|$)' . It matches the lines git itself counts as markers, including ones followed by a carriage return. Inside a repository, git grep with the same pattern and HEAD checks what was committed.
Merge conflict marker encountered: what does "leftover conflict marker" mean?
It is the message git diff --check prints for each marker line still in a change. The file and line number come first, as in trip.md:5: leftover conflict marker. In the receipt the command exited with status 2. Open that line, resolve the conflict, delete the marker, and run the check again until it is silent.
Git how to remove conflict markers from files?
Open the file in a source or plain-text view, keep the version you want, and delete the <<<<<<<, ======= and >>>>>>> lines, plus any ||||||| section. To take one whole side while the conflict is open, run git checkout --theirs -- file.md or --ours. Then run git diff --check before staging.
How do I stop git from committing conflict markers?
Plain git add and git commit allow them; in the receipt the commit exited 0. Run git diff --cached --check first, or enable git's sample pre-commit hook, which runs the same check and refused the commit. Note that the hook also refuses trailing whitespace — including Markdown's two-space line break — and --no-verify skips it.
Does git add --resolved catch every leftover marker?
No — the Git 2.56 option scans only paths git still considers unmerged, and refuses to stage anything if one of them has markers. A note already staged with plain git add, or a marker committed earlier, is never checked. Use it alongside grep and git diff --check, not instead of them.
A rendered note is an interpretation of a file; when two versions of a line are fighting inside it, only the file tells you so.
This post rests on git's documentation and source, on the CommonMark specification's account of setext headings, and on Alex Georgiev's hands-on test of git add --resolved.
mnmnote.com keeps notes as open Markdown on your own device — text you can export and search with any tool, including the grep above.
Footnotes
-
MNMNOTE, measured render run, 22 November 2026. Five conflicted notes produced by a real
git merge(git 2.53.0), rendered with markdown-it 14.3.3 (commonmarkand default presets), commonmark.js 0.31.2, marked 18.2.1, micromark 4.0.3, micromark 4.0.3 with micromark-extension-gfm 3.0.0, and GitHub's Markdown API (POST /markdown, modegfm). The diff3 note and the note with Windows line endings went through the six local configurations. ↩ ↩2 ↩3 ↩4 ↩5 -
MNMNOTE, "When Two Devices Edit the Same Note." https://blog.mnmnote.com/posts/when-two-devices-edit-the-same-note ↩
-
MNMNOTE, measured git run, 22 November 2026, git 2.53.0 in a scratch repository: grep pattern comparison, plain
git addandgit commitwith markers in place,git diff --checkon unstaged, staged and committed changes, git's sample pre-commit hook,git commit --no-verify, andgit checkout --theirs. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 -
Git documentation,
git-merge, section "How conflicts are presented". https://git-scm.com/docs/git-merge Accessed 2026-11-22. ↩ ↩2 -
Git documentation,
gitattributes, "conflict-marker-size". https://git-scm.com/docs/gitattributes Accessed 2026-11-22. ↩ ↩2 -
CommonMark Spec, version 0.31.2 (2024-01-28), ed. John MacFarlane, §4.3 "Setext headings". https://spec.commonmark.org/0.31.2/#setext-headings Accessed 2026-11-22. ↩ ↩2 ↩3
-
CommonMark Spec, version 0.31.2 (2024-01-28), §5.1 "Block quotes". https://spec.commonmark.org/0.31.2/#block-quotes Accessed 2026-11-22. ↩
-
MNMNOTE, "Navigate a Long Note by Its Outline (No App Feature Needed)." https://blog.mnmnote.com/posts/navigate-a-long-note-by-its-outline ↩
-
Git source code, v2.56.0,
merge-ll.c, functionis_conflict_marker_line(). https://github.com/git/git/blob/v2.56.0/merge-ll.c ↩ -
MNMNOTE, "Line Endings in Your Notes: Why the Same File Looks Different on Windows, Mac, and Linux." https://blog.mnmnote.com/posts/line-endings-in-your-notes-crlf-or-lf ↩
-
Git documentation,
git-diff, option--check. https://git-scm.com/docs/git-diff Accessed 2026-11-22. ↩ -
Git documentation,
githooks, v2.56.0, "pre-commit". https://github.com/git/git/blob/v2.56.0/Documentation/githooks.adoc ↩ -
Git source code, v2.56.0,
templates/hooks/pre-commit.sample. https://github.com/git/git/blob/v2.56.0/templates/hooks/pre-commit.sample ↩ ↩2 -
Git project, "Git v2.56 Release Notes" (Git 2.56.0, released 28 September 2026). https://github.com/git/git/blob/v2.56.0/Documentation/RelNotes/2.56.0.adoc ↩
-
Git documentation,
git-add, option--resolved. https://git-scm.com/docs/git-add Accessed 2026-11-22. ↩ -
Git source code, v2.56.0,
builtin/add.c, functionadd_resolved_files(). https://github.com/git/git/blob/v2.56.0/builtin/add.c ↩ ↩2 -
Alex Georgiev, "Git 2.56's git add --resolved only checks conflict markers while git still calls a file unmerged," dev.to, 17 November 2026. https://dev.to/alexgeorgiev17/git-256s-git-add-resolved-only-checks-conflict-markers-while-git-still-calls-a-file-unmerged-jgm Accessed 2026-11-22. ↩ ↩2 ↩3
-
Stack Overflow, questions 7901864 ("Git conflict markers"), 58325295 ("Merge conflict marker encountered") and 914939 ("Simple tool to 'accept theirs' or 'accept mine' on a whole file using git"), view counts via the Stack Exchange API, read 22 November 2026. https://stackoverflow.com/questions/7901864/git-conflict-markers ↩ ↩2
-
ViscousPot, "feat: merge conflict resolution UI in editor," Vinzent03/obsidian-git pull request #1175, merged 19 September 2026. https://github.com/Vinzent03/obsidian-git/pull/1175 Star count read 22 November 2026. ↩ ↩2 ↩3 ↩4
-
MNMNOTE, "Version Control Is Having a Moment. Your Notes Deserve a History You Own." https://blog.mnmnote.com/posts/version-control-is-having-a-moment-your-notes-deserve-one-too ↩
-
MNMNOTE, "Write “[Status]: draft” in a Markdown Note and the Line Disappears." https://blog.mnmnote.com/posts/a-line-like-status-draft-disappears-from-your-markdown-note ↩