Your problem is real, but this premise is a bit faulty here:
[git ls-files -u
] ... only lists files that are currently conflicted (i.e. they have the <<<<<<<<<<<
markers)
The git ls-files -u
output does not depend on what is in your working tree, but rather on what is in Git's index (aka staging area ). What this means for you is:
Partway through the process, I realize that I may have resolved some conflicting files incorrectly.
If you have not yet run git add
on your resolved files, git ls-files -u
will still list them.
Alas, if you have run git add
on the resolved files, it won't. Git does have, stored in special "REUC" entries, enough information to reconstruct the conflicts, but there's no easy way to access these.
The quickest and simplest way to get a list of conflicted files—which also gets you Git's attempt at merging them—is to use git worktree add
to add a second working tree at the same commit as the current commit, then re-perform the merge command in that second working tree. (The added working tree has its own index/staging-area.) For instance:
git worktree add --detach ../recreate-conflict HEAD
You can now open a new window and maneuver (or manoeuvre if you're British) to the appropriate directory and run git merge <other>
there as before, or in bash, pushd ../recreate-conflict
and do it in the current window.
Leave the added working tree in place as a handy consultation location until you're satisfied that you've done the merge correctly. You can leave it around as long as you want, even after committing a merge from the main working tree: it's just occupying some disk space with a checkout and the in-progress merge.
(Use git worktree remove
to clean it out when you're done with it, or use the OS's "remove entire tree" option on it, then run git worktree prune
. You can do either of these from the main working tree.)