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?
"git merge -Xrenormalize" works like a charm.
AFAICT, (I haven't tried it) you could use
git diff
to compare the branch you want to merge to the common ancestor, then apply the results withgit apply
. Both commands have--ignore-whitespace
options to ignore line ending and white space errors.Unfortunately, if the patch doesn't apply cleanly, the whole operation is aborted. You can't fix merge conflicts. There is a
--reject
option to leave unpatchable hunks in.rej
files, which helps, but isn't the same as having the merge conflicts shown in one file.http://stahlforce.com/dev/index.php?tool=remcrlf
I tried it, but if after the last line in your code you didn't already have CRLF it adds by itself a LF and the file looks changed in git. Other than that it works.
After reading https://stackoverflow.com/a/12194759/1441706 and https://stackoverflow.com/a/14195253/1441706
for me, this command did the trick perfectly:
After reading Resolve merge conflicts: Force overwrite all files
I finally resolved my version of this issue. I was trying to pull updates from the upstream repo but my current one was having CRLF related issues and was unable to merge as result. It should be noted I had NO LOCAL CHANGES i needed to worry about. The following steps resolved my issue:
As per github's instructions on syncing forks (https://help.github.com/articles/syncing-a-fork/):
git fetch upstream
git reset --hard upstream/master
My limited understanding of git tells me this is doing what i want-- rebasing my fork (with no actual uncommitted changes) to gain all the changes made to the upstream source. According to the source page, this step should normally not be required, but the CRLF issue made it required.
git merge upstream/master
git push
It doesn't look like this can be done directly but this post suggests a work around.
http://osdir.com/ml/git/2009-02/msg02532.html