正在设置自定义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

有可能吗?

如果希望git config使用不同于例如~/.gitconfig(带有--global(的文件,请使用--file标志。

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

有关详细信息,请考虑man git-config

执行

git config --edit --global

并添加行

[include]
path = ~/someotherfile

最新更新