• Register
0 votes
1.5k 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 49 views
49 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
2 answers 297 views
297 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 34 views
34 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
1 answer 69 views
69 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 170 views
170 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, 2020 jwilliam 3.9k points
0 votes
2 answers 3K views
3K views
Problem : On the branch I had some files in the .gitignore On the different branch those files are not. I am trying to merge the different branch into my branch, and I don't bother if those files are no longer overlooked or not. Unfortunately I get below ... by merge” How should I modify the pull command to overwrite those files, without needing to find, move or delete those files by myself?
asked Jan 6, 2020 alecxe 7.5k points
1 vote
2 answers 1.6K views
1.6K views
Problem : On the branch which I had some of my files in .gitignore On the different branch those files are not present. So I want to merge the different branch into my branch and I really do not care about those files if they are no longer ignored or not. But ... by merge How can I modify the pull command to overwrite the files, without me needing to find, move or delete the files by myself?
asked Dec 27, 2019 alecxe 7.5k points
0 votes
1 answer 12 views
12 views
Problem: Hello Kodlogs, I am a new Python learner. I was planning to learn computer programming and one of my friends suggested me start the journey with Python. I installed python on my machine and started writing codes. Well, everything was good until I feel that I’ ... If it is possible, please provide me a way to do that. I am looking forward to reading your answers. Thanks in advance.
asked Jul 5, 2020 adamSw 11.3k points
0 votes
1 answer 137 views
137 views
Problem : How can I ignore the below error message on the Git pull? Your local changes to the following files would be overwritten by merge What if I just want to overwrite them? I Have already tried many things like git pull -f, but nothing really works for me.To be very clear, I just want to overwrite the specific changes and not the everything.
asked Jan 2, 2020 alecxe 7.5k points