3

We have a team of people working on a centralized git repository, each with a different OS / editor.

What would be a sane configuration (locally for each developper, or on the server itself ?) to avoid line ending conflicts ?

So far we've found "documentation" about a magic "autocrlf" property, but we can't figure out what value it should have (a common problem with 'ternary boolean parameters'.)

core.autocrlf Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in your working directory even though the repository does not have normalized line endings. This variable can be set to input, in which case no output conversion is performed.

Can we trust the non-official doc here ( http://git-scm.com/book/ch7-1.html ), and use

On a Windows Machine :

  • git config --global core.autocrlf true
  • Let your editor use CRLF

On a Linux or OSX Machine :

  • git config --global core.autocrlf input
  • Let your editor use LF

How would line returns be stored on the server ?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
phtrivier
  • 13,047
  • 6
  • 48
  • 79

1 Answers1

0

Don't use a global repository-wide settings.

I would recommend:

git config --global core.autocrlf false

By default, Git don't touch the eol of your file (which is a good thing, especially for binary files which could be corrupted because of an "automatic conversion")

Then, if you need to manage eol for specific files or type of files, use core.eol settings, in a .gitattributes file, as explained in "Distributing git configuration with the code".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250