(March 2012) It looks like this is finally going to be possible soon -- git 1.7.10 is going to support 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:
Path expansion, e.g. ~ or $HOME, does not appear to be supported.
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.
Repository specific configuration file. (The filename is of course relative to the repository root, not the working directory.)
~/.gitconfig
User-specific configuration file. Also called "global" configuration file.
$(prefix)/etc/gitconfig
System-wide configuration file
Config File inclusion was discussed in May 2010, and a first patch was written by Ævar Arnfjörð Bjarmason, but I don't see this patch in one of the latest "what's cooking in Git".
发布评论
评论(2)
(2012 年 3 月)看起来这最终将很快成为可能——git 1.7.10 将在
.gitconfig
中支持此语法:请参阅此处了解 git 更改及其边缘情况的详细说明。
,有几个细节值得指出:
路径扩展,例如
~
或$HOME
,似乎不受支持。如果指定了相对路径,则它是相对于具有
[include]
语句的 .gitconfig 文件。即使跨链包含,这也能正常工作——例如~/.gitconfig
可以有:<前><代码>[包括]
路径=子目录/gitconfig
和
subdir/gitconfig
可以有:<前><代码>[包括]
路径=nested_subdir/gitconfig
...这将导致
subdir/nested_subdir/gitconfig
被加载。如果 git 找不到目标文件,它会默默地忽略该错误。这似乎是设计使然。
(March 2012) It looks like this is finally going to be possible soon -- git 1.7.10 is going to support this syntax in
.gitconfig
:See here for a detailed description of the git change and its edge cases.
By the way, a couple of subtleties worth pointing out:
Path expansion, e.g.
~
or$HOME
, does not appear to be supported.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:and
subdir/gitconfig
can have:... 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.
(2012 年 3 月):正如 Mike Morearty 的 答案(我赞成),git 1.7.10+ 将支持此功能。
原始答案(2010年10月):
目前还没有。
正如我在中提到的,是否可以将文件包含在在您的
.gitconfig
中,您已经有 3 个单独的 gitconfig 供您组织设置:2010 年 5 月讨论了 配置文件包含问题,并发布了第一个补丁由 Ævar Arnfjörð Bjarmason 编写,但我在最新的“Git 正在做什么"。
(March 2012): As mentioned in Mike Morearty's answer (which I upvoted), git 1.7.10+ will support this feature.
Original answer (October 2010):
Currently, no.
As I mentioned in Is it possible to include a file in your
.gitconfig
, you already have 3 separate gitconfig for you to get your settings organized:Config File inclusion was discussed in May 2010, and a first patch was written by Ævar Arnfjörð Bjarmason, but I don't see this patch in one of the latest "what's cooking in Git".