Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How share a config file in git?

Tags:

git

git-config

I have editor settings that I want to spread in all repositories. If the user defines its own settings, it should erase the repository choices of course.

I want to do that because I have a class and every student clone the repo. Usually they forget to set the core.editor setting and ends up messing around with vi, usually crashing the repo just like if they have cursed magical power.

As it worked for my HOME dir, I tried to use a .gitconfig in my repo dir, like I would set a .gitignore, but it doesn't seem to work.

EDIT :

  • --global DOES let the user set its preference to override the repo, but it DOES'T allow him to fetch the repos config while cloning it.
  • .git/config is not shared among cloned repo
like image 256
e-satis Avatar asked Feb 11 '10 17:02

e-satis


People also ask

How do I access 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

Distribute your repo using rsync or tar/untar, rather than using "git clone", which as you have seen, does not copy repo-special files.

like image 74
Randal Schwartz Avatar answered Oct 13 '22 04:10

Randal Schwartz


I do this by moving the config file up to the working dir to get it versioned.

Then you could ask the other person to make a link to the config:

$ rm .git/config
$ cd .git
$ ln -s ../config config

You could then write this in a script or in one line to let them copy and paste.

like image 45
vcastellm Avatar answered Oct 13 '22 05:10

vcastellm