2014年10月28日 星期二

解決 git commit 時出現 ^M 的討厭問題.

find . -type f -not -path "./.git/*" -exec dos2unix {} \;
git commit -a -m 'dos2unix conversion'
2) Set core.autocrlf to input on Linux/UNIX or true on MS Windowns (repo or global)
git config --global core.autocrlf input
3) [ Optional ] set core.safecrlf to true (to stop) or warn (to sing:) to add extra guard comparing if the reversed newline transformation would result in the same file
git config --global core.safecrlf true

B. Or per Repo Setup

1) Convert all to one format
find . -type f -not -path "./.git/*" -exec dos2unix {} \;
git commit -a -m 'dos2unix conversion'
2) add .gitattributes file to your repo
echo "* text=auto" > .gitattributes 
git add .gitattributes 
git commit -m 'adding .gitattributes for unified line-ending'
dont worry about your binary files - git should be smart enough about them

【下列文章您可能也有興趣】

沒有留言: