I tried committing files with CRLF-ending lines, but it failed.
I spent a whole work day on my Windows computer trying different strategies and was almost drawn to s
Using core.autocrlf=false
stopped all the files from being marked updated as soon as I checked them out in my Visual Studio 2010 project. The other two members of the development team are also using Windows systems so a mixed environment didn't come into play, yet the default settings that came with the repository always marked all files as updated immediately after cloning.
I guess the bottom line is to find what CRLF setting works for your environment. Especially since in many other repositories on our Linux boxes setting autocrlf = true
produces better results.
20+ years later and we're still dealing with line ending disparities between OSes... sad.
Don't convert line endings. It's not the VCS's job to interpret data -- just store and version it. Every modern text editor can read both kinds of line endings anyway.
Two alternative strategies to get consistent about line-endings in mixed environments (Microsoft + Linux + Mac):
1) Convert all to one format
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 Windows (repository 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
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 repository
echo "* text=auto" > .gitattributes
git add .gitattributes
git commit -m 'adding .gitattributes for unified line-ending'
Don't worry about your binary files - Git should be smart enough about them.
More about safecrlf/autocrlf variables