Paul
Paul

Reputation: 26660

Turn Git CR-LF conversion off (not the warning message) in year 2022

There are plenty of resources that list several Git settings, like core.autocrlf or settings in .gitattributes file, to either turn CRLF auto conversion warning off or the conversion itself but none of them seems to work in year 2022 for git 2.27.0.windows.1.

Actually I would like to have following:

Please suggest a working solution for now.

Upvotes: 0

Views: 64

Answers (1)

bk2204
bk2204

Reputation: 76539

To Git, the text attribute for a file means to perform line-ending conversion. If you don't want to perform line-ending conversion, then you don't want to set the text attribute.

If you simply want to always commit files as they are, then you either need to do one of the following:

  1. Set * -text in .gitattributes. Diffs will still do autodetection for whether the file is text or binary.
  2. Don't specify anything in .gitattributes and always set core.autocrlf to input. This relies on every user of the repository having the same settings and therefore isn't recommended.

Those are the two options that are available: there are no other options to turn off line-ending conversion in Git.

Note that in both cases, Git will perform no input or output conversions at all, so no LF to CRLF conversion will be performed. Similarly, Git will by default show carriage returns as trailing whitespace in new lines of diffs.

Upvotes: 1

Related Questions