32

I am using Git gui. I see this error for several files in a folder. I have two choice buttons - Unlock index and Continue. I don't understand what the buttons do. I saw other SO posts which tell me to ignore the warning, but they don't mention how to do it in GUI. Please tell me which button I should press and why. Thanks.

Here is the error message sample -

Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui.

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. (repeat above messages for other files)

Anatoly
  • 20,799
  • 3
  • 28
  • 42
james
  • 1,667
  • 5
  • 26
  • 38
  • 2
    sample post - http://stackoverflow.com/questions/12510238/updating-the-git-index-failed-lf-will-be-replaced-by-crlf – james Jul 15 '14 at 17:01
  • I pressed continue. I can't wait for replies. Hope it did not mess things up. – james Jul 15 '14 at 17:11
  • read my answer, run the CLI command and your errors should go away :-) – CodeWizard Jul 17 '14 at 08:54
  • Possible duplicate of [LF will be replaced by CRLF in git - What is that and is it important?](https://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important) – Stevoisiak Nov 08 '17 at 17:02
  • Does this answer your question? [git replacing LF with CRLF](https://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf) – kenorb Jun 25 '20 at 17:34

7 Answers7

31

Set up the CRLF and the problem will "disappear"

# Option 1:
git config --global core.autocrlf false

# Option 2:
`git config --global core.safecrlf false`

https://help.github.com/articles/dealing-with-line-endings

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • 5
    I have seen this link before. It tells me nothing about the GUI options. – james Jul 16 '14 at 16:07
  • 6
    The question might not be ideally asked, but it is clear: "Please tell me which button I should press and why.", that is at `git gui` level. Thank you for this answer, but it mainly requests the user to perform some global change at `git` level (not `git gui`) with permanent effect on all present and future repositories, without any explanation about what's actually happening or what the initial issue means. Are you sure that the command is actually what the user (or future readers of the question) need? – Stéphane Gourichon Jan 30 '17 at 13:57
  • 6
    I think setting **autocrlf** to false is not a good idea. Mac and Windows deal with line endings differently. I would only set it to false if completely sure that I will work only in PC. – adelriosantiago Sep 12 '17 at 02:28
  • It is not `autocrlf` matters, but `safecrlf`. – lzhh Aug 06 '21 at 23:46
13

It is not autocrlf matters, but safecrlf. Use below command to suppress the warnings.

git config --global core.safecrlf false

autocrlf is to control whether transform line endings when add/checkout, while safecrlf is to control whether warn users when doing such transformations.

lzhh
  • 852
  • 7
  • 16
5

To add onto @Code Wizard's solution here: https://stackoverflow.com/a/24770798/19037789 ,

You can also run the following command to set your CRLF locally, only to the specific project you're working on:

git config --local core.autocrlf false
4

Soo, i'm have that problem too. I fix it, simple, using by IDE. have a problem

Use IDE (intellij idea). use IDE

And then after use IDE.. no problem) no problem)

1

I had the same problem and then i fixed it using git config --global core.safecrlf false

  • 2
    Thanks for letting us know! In that case, though, you should be upvoting the answer with the same solution that's been around for a year now: https://stackoverflow.com/a/68688405/177710. – Oliver Jun 11 '22 at 11:08
  • the person doesn't have enough rep to upvote yet – Ooker Nov 16 '22 at 10:23
0

I made some tests and the 2 buttons' behavior is identical. Nothing changed on the file content. I expected an LF -> CRLF replacement. Instead of that (in both cases) I got an error message:

wrong # args: should be "ui_status msg"
    while executing
"ui_status [mc "Ready to commit."] ui_ready"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 $after"
    (procedure "select_first_diff" line 8)
    invoked from within
"select_first_diff $after "
    (procedure "rescan_done" line 15)
    invoked from within
"rescan_done $fd buf_rlo $after"
    (procedure "read_ls_others" line 14)
    invoked from within
"read_ls_others file2a1c920 {ui_status [mc "Ready to commit."] ui_ready}"

Getting rid of this (for Windows):

In my case, I discovered bad settings of my Notepad++ settings. The use of Unix LF in the newly created documents So at staging between my documents were files using CRLF (the old ones) and files using just LF (the new ones). I converted the newly created document to use CRLF. Because in my opinion is better to have all the file in the same format ... You can use the first comment option. In this case, the tool will omit this (newline) check!

William Prigol Lopes
  • 1,803
  • 14
  • 31
0

To fix this issue of line ending you configure git for Windows like this:

git config --global core.autocrlf true

For MacOs/Linux users you configure it as:

git config --global core input
Sercan
  • 4,739
  • 3
  • 17
  • 36
veldo
  • 1
  • 1