我如何指定自定义全局gitconfig路径? [英] How can I specify custom global gitconfig path?
问题描述
我有一个绑定与 Git
。我试图执行 git commit
但我需要能够在〜/ .gitconfig1
和〜/ .gitconfig2
有一个命令行开关 - 或者无论如何有 Git
使用不同的gitconfig文件, / etc / gitconfig
,〜/ .gitconfig
和 .git / config
?
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
?
推荐答案
我发现一种方法来执行这个 - 它不优雅,但它确实工作 - 似乎是让这个工作的唯一方法。
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使用 HOME
路径来确定 .gitconfig
是。我可以执行这样的操作:
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
Git提交(这是唯一需要 .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"
$ b b
You can then use alias to do this easily
alias sillygit="HOME=/home/marco/.silly/ git"
sillygit commit -m "silly stuff"
这篇关于我如何指定自定义全局gitconfig路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!