Git 2.56 shipped a new flag for the oldest bad habit in merge conflict resolution: typing git add . the moment the markers are gone, and staging whatever else happened to be sitting in the working tree at the same time.
git add --resolved is supposed to fix that. It stages only the paths git still considers unmerged, and it is meant to refuse if any of those paths still contain leftover conflict markers. I built it from source, because the Ubuntu 24.04 container I was working in only had 2.43.0, and ran it against a handful of conflicts I created on purpose.
The core promise held up. The safety check around it had a gap I didn't expect.
Setting it up
Git 2.56.0 isn't in Ubuntu's repositories yet, so I built it from the kernel.org tarball:
$ ./configure --prefix=$HOME/git-2.56 $ make -j4 NO_GETTEXT=1 NO_TCLTK=1 NO_CURL=1 $ make install NO_GETTEXT=1 NO_TCLTK=1 NO_CURL=1 $ ./git-2.56/bin/git --version git version 2.56.0 I skipped curl and gettext support because the testing only needed local commands. git add -h confirmed the flag is there:
--[no-]resolved add conflict-resolved tracked files The core promise: it does ignore unrelated files
I built a repo with two branches that both edit file1.txt and file2.txt, merged them to force a conflict, resolved both files properly, and then made an unrelated edit to a third file, file4.txt, that had nothing to do with the merge.
| Command | file1.txt (resolved) | file2.txt (resolved) | file4.txt (unrelated edit) |
|---|---|---|---|
git add . | staged | staged | staged |
git add --resolved . | staged | staged | left unstaged |
That's the whole pitch, and it's real. After git add --resolved ., git status --short showed:
M file1.txt M file2.txt M file4.txt The leading column is the staged state and the second is the working-tree state. file4.txt has a space in the first column, meaning nothing about it is staged. With plain git add . on the same working tree, all three files come back M in the index column. If you've ever committed a stray console.log or a half-finished change because it happened to be sitting in the tree during a conflict resolution, this removes that failure mode outright.
What it refuses, and what I got wrong on the way
The second claim is that --resolved checks the paths it's about to stage for leftover <<<<<<< markers and aborts if it finds any. My first attempt to test this looked like it had found a bug: I resolved one file, left markers in the other on purpose, ran the command, and got exit code 0 with nothing printed and nothing staged.
That looked like a silent no-op where the documentation promised an error. It wasn't. The problem was my test harness, not the flag. In the run before that one, I had already run git add --resolved . successfully once on that same working tree and then called git reset to put things back for the next scenario. git reset rewrites the index against HEAD, and in doing so it collapses the unmerged (stage 1/2/3) entries into ordinary staged-then-unstaged entries. By the time I reintroduced the markers, git no longer considered those paths unmerged at all, so --resolved had nothing to look at and correctly did nothing. I was testing a file that looked conflicted to a human and wasn't conflicted to git.
Once I rebuilt the conflict from scratch instead of reusing a reset repo, the refusal showed up exactly as documented:
$ git add --resolved . fatal: the following paths still have conflict markers: file2.txt Exit code 128. And it's atomic: file1.txt was fully and correctly resolved in that same run, but it stayed UU in the index alongside the broken file2.txt. --resolved does not partially stage the paths it's happy with; one bad file blocks the whole invocation. Only after I actually removed the markers from file2.txt did the second run stage both files.
The gap: the check only applies while git calls a file unmerged
The accidental discovery above pointed at something real, so I tested it on purpose. I merged two branches with one conflicting file, left the file with genuine, un-removed <<<<<<< markers, and ran git add --resolved -v . against it while there was no merge in progress and no unmerged entry for that path at all — just an ordinary tracked file with marker text sitting inside it from an earlier git reset.
$ git status --short M file1.txt $ git add --resolved -v . $ echo exit: $? exit: 0 No output, even with -v. Nothing staged. The file still contains real <<<<<<< and ======= and >>>>>>> lines, and --resolved walked straight past it, because the only thing it checks is whether the path is in conflict stages in the index right now, not whether the file's content looks like a conflict. The marker scan is a guard on top of "this file is still unmerged," not a general scan for marker text in tracked files. If you've already run any add/reset sequence that clears the unmerged bit — including, ironically, a first successful use of --resolved itself followed by amending something — the safety net is gone and the next --resolved call will happily do nothing, silently, on a file that still has markers in it.
The other gap: it doesn't look inside a file
I then resolved a conflict and, in the same edit, added one extra unrelated line to the same file, to see whether --resolved could tell the two apart:
line1 main change +A change +UNRELATED DEBUG LINE I FORGOT TO REMOVE git add --resolved . staged this without complaint. The flag's unit of "unrelated" is the file, not the line. It stops you from staging file4.txt because it's a different path. It will not stop you from staging a debug line you left in the middle of the file you were actually supposed to be fixing.
What it costs
I timed git add --resolved . against plain git add . on a repo with 3,000 genuinely conflicting files, all pre-resolved, five runs each:
| Run | add --resolved | add |
|---|---|---|
| 1 | 0.202s | 0.196s |
| 2 | 0.223s | 1.404s |
| 3 | 0.202s | 0.230s |
| 4 | 0.439s | 0.168s |
| 5 | 0.820s | 0.175s |
The spread swamps the difference. I expected scanning every conflicted file's content for marker strings to show up as a consistent tax on top of ordinary staging, and it didn't: the two distributions overlap, and the single slowest run in the whole table (1.4s) belongs to plain add, not --resolved. On this machine, at this scale, the marker check is not a cost worth worrying about.
Run it yourself
#!/bin/bash set -e GIT=/path/to/git-2.56/bin/git $GIT init -q -b main repo && cd repo $GIT config user.email t@t.com && $GIT config user.name T echo base > a.txt; echo base > b.txt $GIT add . && $GIT commit -q -m base $GIT checkout -q -b branchA echo "A change" >> a.txt; echo "A change" >> b.txt $GIT commit -q -am branchA $GIT checkout -q main echo "main change" >> a.txt; echo "main change" >> b.txt echo "unrelated edit" >> c.txt $GIT commit -q -am main set +e $GIT merge branchA # conflicts in a.txt and b.txt set -e # resolve a.txt and b.txt by hand: printf "base\nmain change\nA change\n" > a.txt printf "base\nmain change\nA change\n" > b.txt $GIT add --resolved . $GIT status --short # c.txt stays unstaged I ran this exact sequence while writing the post and it produces the table above.
What to do with this
If your merge workflow still ends in git add ., switching to git add --resolved removes a real failure mode: unrelated dirty files no longer ride along into the merge commit, for free, with no measurable cost. Don't treat the marker check as a general-purpose guard against committing broken conflict markers, though. It only fires while git's index still thinks the path is unmerged. If you've run any sequence that clears that state — a reset, an aborted add, a rebase that re-touches the same path — check the file yourself before you commit, because --resolved will not catch it, and it will not tell you it didn't.

