如何指定自定义全局 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 Commit(这是唯一需要 .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"
这篇关于如何指定自定义全局 gitconfig 路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!