Sujit_Mohanty
Sujit_Mohanty

Reputation: 47

What does it mean LF will be replaced by CRLF the next time git touches it

Why is it showing warning when I added a file to the staging area using git add -A and the following message appeared:

enter image description here

What does it mean ?

Upvotes: 3

Views: 23746

Answers (4)

dan1st
dan1st

Reputation: 16348

You configured git to check in UNIX line endings (\n) if you have Windows line endings locally (\r\n) and also check out Windows line endings for files with UNIX line endings but you have a file using UNIX line endings locally.

You added a file with UNIX line endings to the staging area. The information tells you that it will replace those UNIX line endings with Windows line endings when git (not you) makes a change to that file.

An example of such a change would be someone else making a change to the remote repository affecting that file and you pulling afterwards. Other examples include checking out that file (or checking out another branch/commit with a different version of the file) or merging something while the file is affected by the merge.

This is just an information telling you that git may change the line endings in the future. If you don't rely on having UNIX line endings, you have nothing to worry about.

If you want to always use UNIX line endings, you can configure core.autocrlf. This can be done using git config --global core.autocrlf input. Setting this configures git to use UNIX line endings in the git repository and also checks out files using UNIX line endings on your local system.

Upvotes: 9

A.Casanova
A.Casanova

Reputation: 1017

LF and CRLF are different formats for the line endings of the files.

This issue may happen if you are toggling both Unix and windows systems.

You can see all the details about the different line endings, in this other question

Upvotes: 3

John M.
John M.

Reputation: 795

git stores files with a common extension with same line ending, either LF or CRLF. You can set which line ending is used in the .gitattributes file. So you may have:

*.sh text eol=lf
*.txt text eol=crlf

git won't update your local file, but if you push a file to a remote repository and pull it again after changes, it will assume the line ending associated with its extension rather than the line endings originally used for the file.

Upvotes: 3

nicholas
nicholas

Reputation: 346

This means that the file will have the line ending encoding change. LF is a line feed, while CR is a carriage return.
Line feed and carriage return MDN Docs

The message states that GIT will replace the 'new line' characters (currently LF) with both CR and LF

Upvotes: 2

Related Questions