When git runs into a merge conflict, its response always seems to be to modify the file by adding conflict markers (a.k.a. "line noise") to the file. Is there a way to make it not do that?
My first choice would for it to leave the file totally unmodified. A very close second would be for it to apply all the non-conflicting edits and keep my local edit for the ones that conflict. (And in either case, mark the files' metadata as needing to be resolved.) Third best would be, in the event of a conflict, abort the whole pull
, stash pop
, etc. before modifying any local state, as if I'd never even attempted it.
Regardless of what git does (its current default or any of my preferences) the very next thing I'm going to do after a conflict is to bring up a diff tool on the local state vs. a clean head (running another git clone
if needed). As such, its attempts to help me by making the conflicts easier to find actually make them harder to understand.
In close to 20 years of using source control, I've yet to have a single situation were what git is trying to make me do was the most productive way to deal with conflicts. The only case I can even think of where it might be more useful would be back 40 years ago when things like GUIs and tmux didn't exist yet. Even then, having it only proceed when I tell it to would be an improvement for how I work.
Edit:
@mkrieger1 pointed out that -Xours
, at least as far as the file content goes, does my option 2. But their quote makes it sound like it will gobble up the conflict and risk me not finding and fixing them.
@qneill pointed out a way to get a --dry-run
effect, which is option 3, but really what I want is just a different file-content when a merge operation fails.