Lf would be replaced by crlf in index html

Важно ли сообщение «LF will be replaced by CRLF in» или можно не обращать внимания?

Привет всем! Помогите разобраться с этим сообщением Git . я так понял этим вопросом задаются все, кто только начал изучать его и я не исключение ) Разбирался, читал, но похоже только больше ещё запутался, что во что конвертируется и в целом нужно ли на это обращать внимание.

Дело такое: я работаю на Виндовс 7, через Git Bash . и в самом Git Bash создал файл .gitignore. Как я понял Git Bash это линуксовая консоль, поэтому она создает файлы с LF.
Поэтому, когда я выполнил команду git add , то появилось это предупреждение: warning: LF will be replaced by CRLF in .gitignore.

Я пытался разобраться самостоятельно, пробовал как в документации прописывал autocrlf = true, но сообщение всё равно появляется.
Поэтому прошу, помогите разобраться . к примеру, если я планирую кросс-платформенную работу над проектом, стоит ли обращать на это сообщение внимание и правильно ли я прописал autocrlf = true (если нет, то как будет правильно)?

Нет правильного, все зависит от того, что вы хотите. Какие разделители строк вы хотите видеть в репозитории? Есть несколько вариантов, lf,crlf,cr, либо не преобразовывать, а записывать как есть. Сейчас вы выбрали преобразовывать в crlf, соответственно если git обнаружит другие переводы строк, то автоматом их преобразует, о чем и пишет в сообщении.

Vitsliputsli Но дело в том, что он изначально так писал, ещё до того как я прописал autocrlf = true, но и с ним тоже самое. Т.е. по умолчанию он всё равно преобразовывает как я понимаю. Это нормально? Если не прописывать ничего, оставить по умолчанию, ничего не собьется? Есть вообще какая то разница, в каком виде они будут хранится в репозитории. Эти переносы влияют на что-то?

Senseich,
autocrlf = true преобразование в crlf, так как принято в Windows,
autocrlf = input преобразование в lf, как принято в Linux,
autocrlf = false не использовать преобразование, а сохранять файл как есть.

Влияют ли или нет переводы на чтото, вам виднее, я же не знаю, что вы храните. Но в любом случае, лучше выбрать тот или иной способ перевода строк, как стандартный для проекта, особенно, если разработчики используют разные платформы. Просто для того, чтобы при сравнении файлы не отличались из-за переводов, хотя современные средства легко игнорируют такие различия, но файл все равно будет фигурировать в git, как измененный.

Читайте также:  Создать свою анимацию css

KodyWiremane

Vitsliputsli, точнее, насколько я понимаю,

true — CRLF→LF при коммите, LF→CRLF при чекауте;
input — только CRLF→LF при коммите;
false — коммитится и чекаутится, да, как есть.

Источник

How to Fix LF Will Be Replaced by CRLF Warning in Git

While using Git, sometimes you may encounter multiple errors and warnings while performing different tasks, such as creating new projects files and folders in different scenarios, such as while tracking files from the working directory to the staging area. The “warning: LF will be replaced by CRLF” is the most common warning you may face while adding files to Git local repository.

This article will discuss the “warning: LF will be replaced by CRLF” and provide the solution to fix it.

What is “warning: LF will be replaced by CRLF” in Git?

The “warning: LF will be replaced by CRLF” mostly occurs when the value of the Git configuration variable is settled as “true”. The reason behind the warning is that the committed files are different from what you saved.

So, to resolve or avoid this warning, you have to change the value of the Git configuration variable using the “$ git config core.autocrlf false” command.

Check out the below-given scenario, which shows us the specified warning.

Step 1: Navigate to Git Folder

First, move to the Git projects root folder using provided command:

Step 2: Create and Move to Git Local Repository

Create a new directory by executing the “mkdir” command and immediately move to it utilizing “cd” command:

Step 3: Initialize Git Repository

Now, run the “git init” command to initialize the Git local repository:

Step 4: Open and Update File

Run the provided command to create a new file and add some text using the redirect operator:

Here, we have added “It’s my first file” text in “file1.txt” through “echo” command:

Step 5: Add File

Next, add the file to the Git staging area using below command:

It can be seen that Git bash threw the mentioned warning when we tried to add the file to the staging area:

Now, let’s move to the next section to fix the “warning: LF will be replaced by CRLF”.

How to Fix “warning: Lf will be replaced by CRLF”?

Now, let’s move toward the below-provided steps to fix the stated warning encountered in the previous section.

Step 1: Check Settings

First, check the default settings of the Git configuration variable value using the provided command:

According to the below output, the Git configuration variable is set as “true”:

Читайте также:  Python list to set time complexity

Step 2: Replace by CRLF Warning Globally(Per User)

Next, we will change the value of the Git configuration variable to “false” with the help of given command:

Step 3: Verify Settings

Now, we will verify the performed operation to ensure the configuration variable value is changed to “false”:

Below-output indicates that the variable value is successfully set to “false”:

Step 4: Replace by CRLF Warning Locally(For the Project Only)

To replace the CRLF warning for the specific local projects, execute the below provided command:

Step 5: Verify Settings

Now, we will run the “git config” command with “core.autocrlf” Git configuration variable to check its configured value:

In the below output, you can see that value is successfully settled to “false”:

Step 6: Add File

Finally, we will add the file to the Git staging area with the help of the given command:

It can be seen that; the file is added successfully:

Step 7: Check Status

Lastly, we will check the Git repository’s current status:

The below output indicates that the new file is added to the Git repository:

That’s it! We have provided the simplest solution to fix the CRLF warning in Git.

Conclusion

Git users mostly encounter the “warning: LF will be replaced by CRLF” when the “autocrlf” Git configuration variable value is configured as “true”. However, you can change its value as “global” per user as well as “local” per project in the “$ git config core.autocrlf false” command. In this article, we have discussed the “warning: LF will be replaced by CRLF” and offered the solutions to fix it.

About the author

Maria Naz

I hold a master’s degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.

Источник

Git — LF Will Be Replaced by CRLF

Git - LF Will Be Replaced by CRLF

LF stands for Line Feed which is a way to represent the end of a line in UNIX-based systems. But in a Windows-based system, a line is usually expressed by CR (Carriage Return) and a line feed (LF).

This problem arises if you use UNIX based system (macOS) to push code, the code will have an LF ending.

If you use a windows machine, make modifications to the code, and do commit, it will be replaced by CRLF since git is smart and does not expect you to use LF on Windows OS.

Similarly, the opposite happens if the warning says, CRLF will be replaced by LF . You will lose windows based CRLF after commit/checkout, and LF will replace it.

Fix LF Will Be Replaced by CRLF Warning in Git

One way to fix the warning is to make changes in config files located in the path where git is installed. The value of code.autocrlf is stored in gitconfig file located at %ProgramFiles(x86)%\git\etc\gitconfig or ProgramFiles\git\etc\gitconfig and in /etc/gitconfig in Linux/Unix based operating systems.

However, we can fix the issue in different situations:

Читайте также:  Что за разрешение php

If you wish to use the project on Unix based OS, you should set the value of core.autocrlf to true

If you wish to use the project under Windows only, the flag should be set to false .

However, in Unix-based OS, you can disable the core.autocrlf per our need.

Before making modifications, you can check the current settings by using the following command,

The command will give output of true or false or input , and you can make changes according to your need.

Fix LF Will Be Replaced by CRLF Warning on the Whole System

To fix the issue systemwide, you can use,

git config --system core.autocrlf false 

Fix LF Will Be Replaced by CRLF Warning Per User

To fix the issue according to the user, you can use,

git config --global core.autocrlf false 

Fix LF Will Be Replaced by CRLF Warning on the Project Only

To fix the issue for a particular project,

git config --local core.autocrlf false 

Ashok is an avid learner and senior software engineer with a keen interest in cyber security. He loves articulating his experience with words to wider audience.

Источник

Почему не выполняется команда git add. ?

Столкнулся с этим впервые, другой проект нормально залился в репозиторий.
Вот порядок действий:

Захожу в локальную папку проекта
cd ~/project

Инициализирую гит
git init

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

После чего выполняю коммит и он пишет:

On branch master Your branch is up-to-date with 'origin/master'. Untracked files:

В гите новичок. Гуглил, способы решения не подошли.

virtyaluk

Инициализируем новый репозиторий
git init

Добавляем файлы (все)
git add .

Если файлы не добавляются, то добавляем каждый вручную
git add README.md

Делаем коммит
git commit -m «First commit»

Пушим
git push -u origin master

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

Olivoin

1654ec32c869445e933edab8ec9782cd.jpg

В GitBash (Windows)
Пишет что заменит LF на CRLF (will be):

1194f5651c3049bf873219617e56d505.jpg

Или он изменяет это в слепках файлов проекта?

Первая строка гугла на запрос «warning: LF will be replaced by CRLF in *file_name*»
stackoverflow.com/questions/5834014/lf-will-be-rep.
Что же вам тут не подошло?

Olivoin

Olivoin

FoxInSox: в конечном итоге мне надо сделать коммит, но он не хочет этого делать, так как файлы находятся в статусе «untracked», и, как следствие, надо выполнить git add . , но он не выполняется

Bloody_Tuna

Сергей Шилов, вопрос как-то решился? я пока что тоже не могу ничего добавить, пересоздавать папки не охото. Помогает только коммит через GitHub Desktop

Связанно это с тем что переносы строк были в Unix-формате, так как дело происходило под Windows.
Простые решения:

Очень просто конвертировать переносы строк в Windows-формат помогает текстовый редактор Notepad++: Правка→EOL конверсия→Преобразовать в WIN-формат.
Подробнее.
Вручную преобразовать символы перевода строки из виндовых в линуксовые, открыть файл, еще раз визуально все проконтролировать и сохранить.
Быстро заменить CRLF на LF можно утилитой dos2unix, входящей в MINGW, с которым поставляется git для win32:

Войдите, чтобы написать ответ

Как пушить нескольким пользователям с одной учетной записи компьютера?

Источник

Оцените статью