I'm quite inexperienced with Git, and this one baffles me:
I just switched my working copy to another branch (a simple git checkout master
), and immediately after that, git status
tells me about hundreds of changed files. However, it's all about line endings; a git diff --ignore-space-at-eol
gives me a lot of warnings:
warning: CRLF will be replaced by LF in src/.../somefile.js.
The file will have its original line endings in your working directory.
I generally consider it a bad idea to have DOS-style line endings in versioned text files, but this is what they have been committed like in the first place; I did this in a Linux box, and the files I got have CRLF line endings.
What is the best way to clean up in my situation? Should I change the line ending of every single file and commit this?
How can Git be configured to avoid such situations in the future?
Try one of these out (depending on your OS):
// Windows
git config --global core.autocrlf true
// Linux, OSX
git config --global core.autocrlf input
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