Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing git conflict markers

Is it possible to change the conflict markers to something user defined?

Motivation:

It has happened several times to me that, due to hasty and not very careful merging of several branches, there are some left over merge tags in my LaTeX document. With most programming projects these tags would result in an syntax error and therefore I would spot them. However, in Latex the <<<<, ==== and >>>> tags are just compiled into some other character sequences without any warning.

To remedy this I would like to change these conflict markers into something that doesn't compile, or at leasts make them very obvious to spot (e.g. page breaks, huge font warnings, or compile warnings).

I could of course make a (bash) script that replaces all those markers by something of my choice, but I would prefer it a more elegant solution to this problem.

P.S. I've found the merge.conflictstyle option, but the diff3 option only adds the |||| marker which also compiles without warning.

like image 967
Laar Avatar asked Jul 09 '12 11:07

Laar


1 Answers

Even if there were a way to make custom conflict markers LaTeX specific (I don't think there is but I could very well be wrong), it might be tough to pick one that worked in all cases. An easier solution would be enabling git's stock "pre-commit" hook, which identifies conflict markers at commit time and rejects the commit if they're present. To enable it:

cd <repo>
mv .git/hooks/pre-commit.sample .git/hooks/pre-commit

The stock hook that ships with git also looks for whitespace errors. To run the check manually, use this command:

git diff --check
like image 63
Christopher Avatar answered Nov 07 '22 02:11

Christopher