Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git, adding files to repository gives fatal error for LF ->CRLF

I'm new to git and I need some help. I'm using msysgit on windows.

When I execute the command git add [folderName] I get the response:

fatal: LF would be replaced by CRLF in [.css file or .js file] 

and then if you try to do a commit nothing happens.

$ git commit # On branch master # # Initial commit # # Untracked files: #   (use "git add <file>..." to include in what will be committed) # #       so01/ nothing added to commit but untracked files present (use "git add" to track) 

Some of these css/js files were downloaded from the net so I guess that's why the have LF. If I open the file and cut/paste the content, then I get the error on the next file and so on.

Any help will be much appreciated.

Edit

Setting core.autocrlf to false seems to solve the problem, but I read on many posts not to set this option to false.

Can somebody point me where can I find out what problems may arise in this situation?

like image 364
user619656 Avatar asked Dec 28 '11 04:12

user619656


People also ask

How do I change from CRLF to LF in git?

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.

Should I use LF or CRLF?

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.

What is LF will be replaced by CRLF?

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.


1 Answers

very new to this so setting core.autocrlf to false didn't make too much sense to me. So for other newbies, go to the config file in you .git folder and add:

[core]     autocrlf = false 

under the [core] heading.

like image 176
sigmapi13 Avatar answered Oct 19 '22 09:10

sigmapi13