Bite code
Bite code

Reputation: 596683

How share a config file in git?

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 :

Upvotes: 15

Views: 3395

Answers (4)

idbrii
idbrii

Reputation: 11916

You could create a shell script in the repo that sets these values through git config. That would allow the students to see how they do it themselves, and it gives them a way to undo their local settings.

Unfortunately, this wouldn't be automatic.

Example:

#! /bin/sh
git config core.editor "ed"

Upvotes: 1

vcastellm
vcastellm

Reputation: 168

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.

Upvotes: 2

Randal Schwartz
Randal Schwartz

Reputation: 44056

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

Upvotes: 5

Alan Haggai Alavi
Alan Haggai Alavi

Reputation: 74202

Global settings can be set via: git config --global

Maybe you should first let the students clone the configuration file (from its own repository) to their home directories.

Upvotes: -4

Related Questions