Is it possible for git merge to ignore line-ending differences?
Maybe I’m asking the wrong question … but:
I tried uisng config.crlf input but things got a bit messy and out of control, specially when I applied it after the fact.
For one thing, applying this config after the fact doesn’t seem to affect files that were committed to the repository before applying this option. Another thing is that suddenly all commits now result in lots of annoying warning messages about CRLF being converted to LF.
To be honest, I don’t really care what line-ending is used, I personally prefer the Unix style \n, but whatever. All I care about, is for git merge to be a bit smarter and ignore the differences in line-endings.
Sometimes I have two identical files, but git would mark them as being in conflict (and the conflict is the whole file) simply because they use a different line ending character.
Update:
I found out that git diff accepts a --ignore-space-at-eol option, would it be possible to let git merge use this option as well?
Update 2013:
More recent git versions authorize using merge with strategy
recursiveand strategy option (-X):But using "
-Xignore-space-change" is also a possibilityjakub.g also comments that the strategies work also with cherry-picking:
This works much better than
ignore-all-space.Before Git 2.29 (Q4 2020), All "mergy" operations that internally use the merge-recursive machinery should honor the
merge.renormalizeconfiguration, but many of them didn’t.See commit 00906d6, commit 8d55225, commit 6f6e7cf, commit fe48efb (03 Aug 2020) by Elijah Newren (
newren).(Merged by Junio C Hamano —
gitster— in commit 4339259, 10 Aug 2020)Original answer (May 2009)
The patch for ignoring eol style has been proposed in June 2007, but it only concerns
git diff --ignore-space-at-eol, notgit merge.At the time, the question has been askeed:
Julio C Hamano was not exactly enthusiastic:
The general idea, when it comes to
git merge, is to rely on the third-party merge tool.For instance, I have setup DiffMerge to be the tool for Git merge, setting a ruleset which allow that merge tool to ignore eol for certain type of files.
Setup on Windows, with MSysGit1.6.3, either for DOS or Git bash session, with DiffMerge or KDiff3:
c:\HOMEWARE\cmd).merge.sh:
Git config commands:
git config at system level:
DOS script (note: the dos2unix command comes from here, and is used to simulate a Unix eol-style. That command has been copied in the directory mentioned at the beginning of this answer.):
At this point (Hitting "return"), DiffMerge or KDiff3 will open, and you will see for yourself what lines are actually merged, and what lines are ignored.
Warning: the result file will always be in Windows eol mode (CRLF) with DiffMerge…
KDiff3 offers to save in one way or another.