I am working on Windows platform, with files in Mac ANSI encoding
when I edit a single line of a file, and then do a git diff
, this is what I see:
diff --git a/class.php b/class.php
@@ -1 +1 @@
-<?php^Mclass Type {^M^M private $x;// level^M ..etc
\ No newline at end of file
+<?php^Mclass Type {^M^M private $x;// level^M ..etc
\ No newline at end of file
In other words, git sees my file as a single line, due to the mac line endings. I have looked at various posts on git hub and got tried a few solutions, but neither worked. I am kind of lost as to what is going on and how to commit my files properly.
Links I have tried:
- git-diff to ignore ^M
- https://help.github.com/articles/dealing-with-line-endings#platform-windows
- http://lostechies.com/keithdahlby/2011/04/06/windows-git-tip-hide-carriage-return-in-diff/
Still same ^M in lines. git does not seem to handle \r on Windows quite well. Must I convert entire repo line endings to say \r\n? Is there not a solution to leave mac encoding as is?
More info:
My .gitattributes file:
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.php text
*.inc text
*.js text
*.txt text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.gif binary
I ran this command: git config --global core.autocrlf true