I am working on Windows, but may also work on Unix, so I don't need to store Windows line endings. I just want to suppress the warning.
I found these related Stack Overflow questions:
I tried the following:
git config core.whitespace cr-at-eol false<Br>
git config core.whitespace cr-at-eol true<br>
git config core.whitespace cr-at-eol nowarn
But these don't seem to do anything. Does anyone know how to turn off the warnings?
text eol=crlf Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux. text eol=lf Git will always convert line endings to LF on checkout. You should use this for files that must keep LF endings, even on Windows.
Go to the config file in this directory: C:\ProgramData\Git\config. Open up the config file in Notepad++ (or whatever text editor you prefer) Change "autocrlf=" to false.
Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.
In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have an LF.
I simply use autocrlf=true
in the .git/config
file to cover most situations in Windows. There are occasional warnings depending on new source files.
If you have special files that don't follow the scheme set up a .gitattributes separately for them e.g. I have Matlab files with *.m eol=lf
.
I used this way:
The git config
core.autocrlf
command is used to change how Git handles line endings. It takes a single argument.On Windows, you simply pass
true
to the configuration. For example:$ git config --global core.autocrlf true # Configure Git on Windows to properly handle line endings
You can also provide a special --global flag, which makes Git use the same settings for line endings across every local Git repository on your computer.
After you've set the
core.autocrlf
option and committed a .gitattributes file, you may find that Git wants to commit files that you have not modified. At this point, Git is eager to change the line endings of every file for you.The best way to automatically configure your repository's line endings is to first backup your files with Git, delete every file in your repository (except the .git directory), and then restore the files all at once. Save your current files in Git, so that none of your work is lost.
$ git add . -u $ git commit -m "Saving files before refreshing line endings"
Remove every file from Git's index.
$ git rm --cached -r .
Rewrite the Git index to pick up all the new line endings.
$ git reset --hard
Add all your changed files back, and prepare them for a commit. This is your chance to inspect which files, if any, were unchanged.
$ git add . # It is perfectly safe to see a lot of messages here that read # "warning: CRLF will be replaced by LF in file."
Commit the changes to your repository.
$ git commit -m "Normalize all the line endings"
source: https://help.github.com/articles/dealing-with-line-endings/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With