So I'm running git in Windows with a repo that runs on *nix, where git checks out Windows-style newlines (line ending CRLF) but commits *nix-style (LF), however I can't get a diff/apply to work without some fatal snag no matter what I've tried.
For example, I run a diff to a file from one commit to another like:
git diff commit1 commit2 > patch.diff
But when I run git apply patch.diff
, I get errors like:
trailing whitespace
patch failed
patch does not apply
I've tried setting git config --global core.autocrlf true
, tried git apply --ignore-space-change --ignore-whitespace patch.diff
, and git config --global core.whitespace cr-at-eol
, and even if it works, the apply shows that almost every line of code was changed just because of the newlines.
If I check the applied patch in something like Git GUI or WinMerge, it shows the proper changes just because they ignore newline changes, but either the diff or apply command is considering the newline differences, and everything I've found on the web to try just doesn't end up with a proper result.
I found something about git rm --cached -r .
but it requires committing all files with "fixed" newlines... which isn't feasible for our project (and shouldn't be necessary).
Am I just not running the right combination or commands and options or what am I supposed to do?