Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distributing git configuration with the code

Tags:

git

In trying to standardise the platform for the developers, one of my needs would be to commit the .git/config so that everybody have the same CRLF config without forgetting to set it by hand.

How do I set this up?

I'm a bit concerned by all this negativity against autocrlf. Why not remove this feature if it doesn't work? Either the makers of this feature are misunderstood or they made a failed experiment with it and it should be removed to stop more people from wasting their time (reading the obscure man page, asking questions, people answering those questions etc.).

like image 831
nraynaud Avatar asked Feb 25 '10 10:02

nraynaud


People also ask

How do I apply a configuration across the entire Git environment?

Git stores all global configurations in . gitconfig file, which is located in your home directory. To set these configuration values as global, add the --global option, and if you omit --global option, then your configurations are specific for the current Git repository. You can also set up system wide configuration.

How do I get to git config?

If you want to check your configuration settings, you can use the git config --list command to list all the settings Git can find at that point: $ git config --list user.name=John Doe user.


2 Answers

I have always found the autocrlf config property problematic. (as expressed in my answer Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination)

  • it not only make some merges tricky
  • it can vary depending on the shell used within one environment
  • it also has issue with git status
  • and with svn import.

Note: msysgit issue 538 for setting it to true (which is the default value set by the msysgit installer), but I am not convinced.

I would prefer one of the three following solutions for:

  • configuring one end-of-line style
  • making that configuration propagate through the different Git repos

First: git config --global core.autocrlf false
Then:

1. Using the new config setting core.eol (1.7.2+)

Sets the line ending type to use in the working directory for files that have the text property set.
Alternatives are 'lf', 'crlf' and 'native', which uses the platform's native line ending.
The default value is native.

2. a checkout/checking .gitattribute. See gitattributes man page: crlf or core.autocrlf is the way to record in a .gitattributes file what is was previously a local config attribute.

You can add checkout/checkin attributes like:

*.vcproj    text eol=crlf *.sh        text eol=lf 

3. a git attribute filter driver which can:

  • enforce any kind of formatting standard you may want to set
  • apply those standards to certain files/directories
  • be recorded as a config file (.gitattributes) able to be pushed anywhere.
like image 71
VonC Avatar answered Sep 23 '22 05:09

VonC


If you're using a Unix family operating system I would recommend just creating a symbolic link.

ln -s .git/config git-config git add git-config git commit -m "Now tracking git config file" 
like image 35
Jason Axelson Avatar answered Sep 19 '22 05:09

Jason Axelson