Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean up line-endings with Git

Tags:

git

eol

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?

like image 804
Tobias Avatar asked Oct 21 '13 07:10

Tobias


1 Answers

Try one of these out (depending on your OS):

// Windows
git config --global core.autocrlf true

// Linux, OSX
git config --global core.autocrlf input
like image 109
yamafontes Avatar answered Oct 22 '22 17:10

yamafontes