2

As it is told in git-config manual, I have three files to specify git repo configuration: $GIT_DIR/config, ~/.gitconfig and $(prefix)/etc/gitconfig. Is it possible to make git read another config file (for example .gitconfig in root of the repo) after reading $GIT_DIR/config?

I want it as I created git command aliases in .git/config and I would prefer to store them in repo, so I can restore them when cloning and for example.

2 Answers 2

5

I wanted to check some of my settings in, so I use an include file. In the root of my repo I have a .myGitConfig file and in my .git\config file I have this:

[include]
    path = ..\\gitconfig

Your syntax may be different if you aren't using Windows. The only trick is that you have to have to add that include line to every .git\config file. That's the best I could come up with. Hope it helps.

3

GIT_CONFIG environment variable and -f command line option are the only ways how to specify custom config file and this will read that single file only.

My informed guess on the answer is You can store the config file in git, but users will have to merge changes to .git/config manually.

Also note that using file under git's control may lead to issues where different branches have different config files with different remotes and branches - seems like a way to ask for troubles.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .