• Register
0 votes
2.4k views

Problem :

I am new to git. I am creating the new rails application but  warning in git about LF replacement. I do git init git add .

and then boom! I see this pop up for almost all files. I always face below warning usually if I build the application then it will disappears after doing many changes to files.

The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in Gemfile.

The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in Gemfile.lock.

The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in README.

I am unable to understand the message. How can I fix the message?

8 4 2
2,300 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I had worked with GIT on both Windows and Unix system so I am familiar with the message which you have posted.

Generally in the Unix your end of a line is always represented with the line feed (LF). And in windows the line is always represented with the carriage return (CR) and your end of line (LF) thus (CRLF). So when you have code from git that was uploaded by the unix system then it will only have the LF.

If you want to turn warning off then you can do it by typing a below command in your git command line

git config core.autocrlf true
5 2 1
4,980 points
0 votes

Solution:

In Unix systems the end of a line is illustrated with a line feed (LF). In windows a line is illustrated with a carriage return (CR) and a line feed (LF) thus (CRLF). At the time you get code from git that was uploaded from a unix system they will just have an LF.

In case you are a single developer performing on a windows machine, and you don't care that git automatically replaces LFs to CRLFs, you can turn this warning off by typing the pursuing in the git command line

git config core.autocrlf true

In case you want to make an intelligent decision how git must handle this, read the documentation:

Formatting and Whitespace:

Formatting and whitespace problems are few of the more frustrating and subtle problems that many developers encounter at the time collaborating, particularly cross-platform. It’s very simple for patches or other collaborated perform to introduce subtle whitespace changes since editors silently introduce them, and in case your files ever touch a Windows system, their line endings might be replaced. Git has a few configuration options to help with these problems.

core.autocrlf

In case you’re programming on Windows and performing with people who are not (or vice-versa), you’ll possibly run into line-ending problems at some point. This is since Windows uses both a carriage-return character and a linefeed character for newlines in its files, on the contrary Mac and Linux systems employ just the linefeed character. This is a subtle however incredibly annoying fact of cross-platform work; many editors on Windows silently replace subsisting LF-style line endings with CRLF, or insert both line-ending characters at the time the user hits the enter key.

Git can handle this by auto-converting CRLF line endings into LF at the time you include a file to the index, and vice versa at the time it checks out code onto your filesystem. You can turn on this functionality with the core.autocrlf setting. In case you’re on a Windows machine, place it to true – this converts LF endings into CRLF at the time you check out code:

$ git config --global core.autocrlf true

In case you’re on a Linux or Mac system that applies LF line endings, then you don’t want Git to automatically convert them at the time you check out files; but, in case a file with CRLF endings suddenly gets introduced, then you may want Git to solve it. You can tell Git to convert CRLF to LF on commit however not the other way around by setting core.autocrlf to input:

$ git config --global core.autocrlf input

This setup must leave you with CRLF endings in Windows checkouts, however LF endings on Mac and Linux systems and in the repository.

In case you’re a Windows programmer doing a Windows-only project, then you can turn off this functionality, recording the carriage returns in the repository by setting the config value to false:

$ git config --global core.autocrlf false

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 6 views
6 views
Problem: what is the meaning of this, and why this happened: the file will have its original line endings in your working directory.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2 views
2 views
Problem: I need someone’s help to fix it... the file will have its original line endings
asked Apr 2 Ifra 24.4k points
0 votes
1 answer 2 views
2 views
Problem: Please help me fix this dilemma: unix command to find a file in a directory and subdirectory
asked 4 days ago tuhin1 48.4k points
0 votes
1 answer 4 views
4 views
Problem: How to copy file from one directory to another in Unix ?
asked Mar 1 Ashty 5.7k points
0 votes
1 answer 2 views
2 views
Problem: I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. need help!!
asked 1 day ago ummesalma 24.5k points
0 votes
1 answer 53 views
53 views
Problem : Whenever I want to copy my 4 files into the bin folder, when I stop the main service, I always face an error with the one particular file (e.g. TexteDll). The error is as follows : Cannot copy TexteDll: The requested operation cannot be performed on a ... may be due to some system locking. Or may be another process is using that DLL. Can someone suggest a cause or solution for this ?.
asked Dec 6, 2019 alecxe 7.5k points
0 votes
1 answer 7 views
7 views
Problem: While writing a cross-platform programme for Windows and Unix , on windows side code compiles and run but on the unix side the code compiles but do not run , it gets a segmentation fault .
asked Feb 25 Ashty 5.7k points
0 votes
2 answers 692 views
692 views
Problem : I have installed Git for Windows but when I try to use git command in Command Prompt I get the following message: 'git' is not recognized as an internal or external command, operable program or batch file.
asked Nov 18, 2019 peterlaw 6.9k points
0 votes
1 answer 3 views
3 views
Problem: Anyone can tell me? thanks
asked Mar 30 Jack20 2.7k points
0 votes
1 answer 1 view
1 view
Problem: I'm trying to add a directory to my path so it will always be in my Linux path. How can I do it so this will be set permanently?
asked 3 days ago ummesalma 24.5k points