Reputation: 31
I don't like git config --global
because I use more accounts.
I also don't like setting config every I wanna clone some repo.
I am looking for something like this:
folder01/
..there is one clonned repo..
folderO2/
..there is two clonned repo..
git config <folder> user.email ...
I need repos in folder inherit the config from parent folder.
Both folder aren't repos, just folder.
I clone repos into some folder and sometimes I remove some repo.
Thanks a lot!
Upvotes: 3
Views: 529
Reputation: 16383
If you only want one config for your system, you could just configure it with git config --system
(as admin/root).
If you want to use the same config for multiple users (but not all users), you can create this config and a link to that config in the home directory of each user.
There is no possibility do that directly(at least I don't know any).
However, there are a few interresting things:
The command git config
has a --file option
. With this, you can configure seperate config files.
You can set the config file for you git config --local include.path "<config file>"
.
With that, you can create a new config file for your directory and when you create a directory, you can just set the config file of a directory using git config --local include.path "<config file>"
.
You can also automate that by writing a script, that automatically scannes all directories for e.g. a config file and executes git config --local include.path "<config file>"
if it finds any files.
That script could look like that(if you use linux/bash):
#!/bin/bash
git init
initDir="$PWD"
while [ "$PWD" != "/" -a ! -f "./.gitconfig" ] ; do
cd ..
done
if [[ -f "./.gitconfig" ]]; then
configFile="$PWD/.gitconfig"
cd $initDir
git config --local include.path "$configFile"
fi
Upvotes: 1