The end of the Git Line Ending Story?

boromir_meme_one_does_not_simply_let_git_handle_line_endings

Git wants to help you handle line endings in text files (which are different on different platforms) so your code can be easily shared across platforms. To be able to help you with this git needs to know what you consider to be text files (and which files you consider to be binary). You do that by adding a .gitattributes file in the repository (alongside the .git folder). The .gitattributes file should at least contain the line * text=auto (the lazy way) which let’s git determine which file are text. However adding a line like: *.txt text or *.jpg binary for each text file type is the most declarative/precise way to tell git which files are text and which files are binary.

An alternative starting point for a .gitattributes file is the one github for windows application creates for you. It looks like this:

# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

If you read only one more thing about this I think you should make it this stackoverflow answer.

Other references: .gitattribute documention https://help.github.com/articles/dealing-with-line-endings#per-repository-settings https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html#_end_of_line_conversion git line ending history (and why it matters) http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/