是否可以在.gitconfig中包含一个文件 [英] Is it possible to include a file in your .gitconfig
问题描述
我想在包含github设置的.gitconfig文件中包含一个文件 - 这可能吗?
我可以这样做:
[core]
include = / path / to / file
$ Git(1.7.10+)now
我想在包含github设置的.gitconfig文件中包含一个文件 - 这可能吗?
我可以这样做:
[core]
include = / path / to / file
$ Git(1.7.10+)now
.gitconfig
:
支持此语法。 code> [include]
path = / path / to / file
请参阅此处详细介绍了git变更及其边缘案例。
顺便提一下,有一些值得指出的细节:
环境变量扩展,例如不支持 $ HOME
。 (扩展名为〜
出现在Git 1.7.10.2中。)
[include]
语句的.gitconfig文件。这甚至可以在链式包括 - 例如〜/ .gitconfig
可以有: [include]
path = subdir / gitconfig
和 subdir / gitconfig
可以有:
[include]
path = nested_subdir / gitconfig
...这会导致加载 subdir / nested_subdir / gitconfig
p>
如果git找不到目标文件,它会默默地忽略错误。这似乎是设计。
I'd like to include a file in my .gitconfig that has my github settings - is this possible?
Can I do something like this:
[core]
include = /path/to/file
Git (1.7.10+) now supports this syntax in .gitconfig
:
[include]
path = /path/to/file
See here for a detailed description of the git change and its edge cases.
By the way, a couple of subtleties worth pointing out:
Environment-variable expansion, e.g. $HOME
, is not supported. (Expansion of ~
appeared in Git 1.7.10.2.)
If a relative path is specified, then it is relative to the .gitconfig file that has the [include]
statement. This works correctly even across chained includes -- e.g. ~/.gitconfig
can have:
[include]
path = subdir/gitconfig
and subdir/gitconfig
can have:
[include]
path = nested_subdir/gitconfig
... which will cause subdir/nested_subdir/gitconfig
to be loaded.
If git can't find the target file, it silently ignores the error. This appears to be by design.
这篇关于是否可以在.gitconfig中包含一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!