Line ending format used in OS
CR
(Carriage Return \r
) and LF
(LineFeed \n
) pairLF
(LineFeed \n
)We can configure git to auto-correct line ending formats for each OS in two ways.
.gitattributes
filegit config --global core.autocrlf input
This will fix any CRLF
to LF
when you commit.
git config --global core.autocrlf true
This will make sure when you checkout in windows, all LF
will convert to CRLF
It is a good idea to keep a .gitattributes
file as we don't want to expect everyone in our team set their config. This file should keep in repo's root path and if exist one, git will respect it.
* text=auto
This will treat all files as text files and convert to OS's line ending on checkout and back to LF
on commit automatically. If wanted to tell explicitly, then use
* text eol=crlf
* text eol=lf
First one is for checkout and second one is for commit.
*.jpg binary
Treat all .jpg
images as binary files, regardless of path. So no conversion needed.
Or you can add path qualifiers:
my_path/**/*.jpg binary