How can I specify custom global gitconfig path?

前端 未结 3 1327
故里飘歌
故里飘歌 2020-12-31 16:56

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 ~/

3条回答
  •  别那么骄傲
    2020-12-31 17:17

    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"
    

    You can then use alias to do this easily

    alias sillygit="HOME=/home/marco/.silly/ git"
    sillygit commit -m "silly stuff"
    

提交回复
热议问题