I'm in a bit of a bind with Git. I'm trying to execute git commit but I need to be able to swtich between ~/.gitconfig1 and ~/.gitconfig2 Is there a command line switch - or anyway to have Git use a different gitconfig file then the ones found at /etc/gitconfig, ~/.gitconfig and .git/config?
views:
27answers:
2
A:
man git-config tells me to use the -f flag to pass a config file. However it doesn't seem to work with other commands than git config, so I think you have to invoke it before committing, easily done with an alias.
bitmask
2010-08-28 21:00:21
That just tells that particular invocation of git-config what file to read or write from - it won't affect any other commands, far as I know.
Jefromi
2010-08-29 04:23:01
Correct - this did not work.
Marco Ceppi
2010-08-29 15:03:49
+2
A:
I found a way to execute this - it wasn't elegant but it did work - and so far seems to be the only way to get this to work.
Git uses the HOME path to determine where .gitconfig is. I was able to perform something like this:
/home/marco/.silly/.gitconfig
/home/marco/.stupid/.gitconfig
/home/marco/.gitconfig
And when executing Git Commit (which is the only command that requires the .gitconfig) I overrode the home path.
HOME=/home/marco/.silly/ git commit -m "silly configuration"
Marco Ceppi
2010-08-29 15:07:58
Nice hack. I can't seem to find any real way to do this - there's a GIT_CONFIG environment variable, but it only affects `git config` itself, in the same way as its `-f,--file` option.
Jefromi
2010-08-29 15:38:28