Failed to update Git index, will LF be replaced with CRLF?

I use git-gui to control versions and push them to remote places. When I tried to rescan the files for changes, I received this message, and I'm not sure what that means. Please help me here.

enter image description here

Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui. warning: LF will be replaced by CRLF in bin/jarlist.cache. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in gen/com/click4tab/pustakalpha/BuildConfig.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in proguard-project.txt. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in project.properties. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in res/layout/start_test.xml. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in res/menu/start_test.xml. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in src/com/click4tab/pustakalpha/StartTestActivity.java. The file will have its original line endings in your working directory. 
+6
source share
4 answers

The solution is to accept this behavior. You are on Windows, so you must have autocrlf as true . This is there, so the end-lines in Git internal reports are consistent. There are warnings so you can see if you are going to accidentally corrupt binary files during commit.

Click Continue . If you want this to not happen in these files, you need to disable these files and then fix the line ends and generate them again. Do this by changing the line ending of the file to CRLF / Windows in your editor or by dragging these command line tools to the system32 directory so you can unix2dos some_file.java in such files on any command line.

+4
source

I encountered similar problems and decided to look more closely at my configuration.

Newline characters in Windows / Linux / MAC:

  • MAC OS up to X: \ r = CR (carriage return)
  • MAC OS X / UNIX: \ n = LF (line feed)
  • Windows: \ r \ n = CR + LF

Do not panic. Git can handle cross-platform conversion for you.

Git should save the line ending as LF in the repo.

Ask it:

TRUE - if you are on Windows :

 git config --global core.autocrlf true 

This will convert the end of LF to CRLF when checking the code.

INPUT - if you are on MAC / LINUX :

You do not need to convert anything, Git uses LF, and your MAC uses LF.

But you can tell Git to convert any CRLF if it passes:

 git config --global core.autocrlf input 

False - not recommended

I do not recommend this, but only for the sake of this explanation:

If you are a windows developer working only on a Windows machine and you are 100% sure that you will never work with people on a MAC:

 git config --global core.autocrlf false 

UPDATE:

As noted below, I did not mention .gitattributes, where you can use these options for the project by default.

If you havetime, here is the document: http://git-scm.com/docs/gitattributes

+2
source

On Unix systems, line endings are represented by linefeeds (LF). In windows, a string is represented by a carriage return (CR) and a line feed (LF), thus (CRLF). when you get the code from git that was downloaded from the Unix system, they will only have LF.

If you want to disable this warning, enter it at the git command line

 git config core.autocrlf true 

If you want to make a smart decision how Git should handle this, read the documentation

Here is a snippet

Formatting and spaces

Formatting and space issues are some of the most annoying and subtle issues that many developers face when working together, especially cross-platform ones. For patches or other collaboration, it’s very easy to make small whitespace changes because editors silently present them, and if your files ever touch the Windows system, their line endings may be replaced. Git has several configuration options to help with these problems.

 core.autocrlf 

If you program on Windows and work with people who aren't (or vice versa), you are likely to run into problems with line endings at some point. This is because Windows uses both a carriage return and a line feed for newlines in its files, while Mac and Linux systems use only a line feed. This is a subtle but incredibly annoying fact of cross-platform work; many Windows editors silently replace existing LF-style line endings with CRLF, or insert both end-of-line characters when the user presses the enter key.

Git can handle this by automatically converting CRLF line endings to LF when you add a file to the index, and vice versa, when it checks the code on your file system. You can enable this function using the core.autocrlf parameter. If you are on a Windows computer, set it to true - this will convert LF endings to CRLF when checking the code:

 $ git config --global core.autocrlf true 

If you are running a Linux or Mac system that uses LF line endings, you do not want Git to automatically convert them when you extract files; however, if a file with CRLF endings is accidentally inserted, you might want Git to fix it. You can tell Git to convert CRLF to LF when committed, but not vice versa by setting core.autocrlf to input:

 $ git config --global core.autocrlf input 

This setting should leave you with CRLF endings in Windows checks, but with LF endings on Mac and Linux systems and in the repository.

If you are a Windows programmer who runs a project for Windows only, you can disable this function by writing the carriage return to the repository, setting the configuration parameter to false:

 $ git config --global core.autocrlf false 
0
source

This line of code should prevent this warning:

 git config core.autocrlf false 

If you want a more detailed answer on how and where you enter this line of code, look here: fooobar.com/questions/874171 / ...

-2
source

Source: https://habr.com/ru/post/1435249/


All Articles