设置自定义git配置文件位置

时间:2019-10-28 20:32:27

标签: git

我正在使用Linux(Tcsh),并且试图设置一个自定义文件,该文件将不在主目录中,该目录可通过以下命令进行访问:

git config --global user.name <user-name>

它在我无法修改的脚本中。

我正在尝试不更改环境变量$HOME的情况。换句话说,类似:

touch mygitconfigfile
./my-script-i-cant-edit
cat mygitconfigfile #has user.name config line

有可能吗?

2 个答案:

答案 0 :(得分:1)

如果您希望git config使用与例如~/.gitconfig(带有--global),请使用--file标志。

git config --file=/path/to/my-git-config-file user.name Robert

请考虑man git-config

答案 1 :(得分:1)

执行

git config --edit --global

并添加行

[include]
    path = ~/someotherfile
相关问题