• Register
0 votes
913 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

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 42 views
42 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 26 views
26 views
Problem : Strange windows error is shown repeatedly unhandled exception has occurred in your application. if you click continue the application will
asked Nov 12, 2019 peterlaw 6.9k points
0 votes
2 answers 102 views
102 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 20 views
20 views
Problem: I am very new to linux, shell and unix. I am assuming that the inputs are given as the command line arguments and if the two numbers are not given then I need to show an error message as "The command line arguments are missing". Sample output as below: The ... the above shell script to add two numbers using the command line arguments from past few days but I am unable to do so as of now.
asked Sep 3 Raphael Pacheco 4.9k points
0 votes
1 answer 122 views
122 views
Problem : I added the folder to the .gitignore file. Once I do the git status it tells me # On branch latest nothing to commit (working directory clean) But when I try to change my branches I get the below: My-MacBook-Pro:webapp marcamillion$ git checkout develop ... /system/images/* public/system/avatars/* How do I get this working for me so I can switch my branches without deleting those files?
asked Jan 22 jwilliam 3.9k points