我可以从另一个加载一个.gitconfig文件吗? [英] Can I load one .gitconfig file from another?

查看:95
本文介绍了我可以从另一个加载一个.gitconfig文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

是否可以在你的.gitconfig文件中包含一个文件


使用bash和zsh,我可以获取子文件以便更好地组织我的配置。



我可以使用 .gitconfig

解决方案

<2012年3月> git 1.7.10将支持 .gitconfig 中的这种语法:

  [include] 
path = / path / to / file

请参阅此处了解有关git更改及其边缘案例的详细说明。



顺便说一句,值得指出的一些细微之处在于:


  1. 路径扩展,例如 $ HOME ,似乎不受支持。


  2. 如果指定了相对路径,则相对于具有 [include] 语句的.gitconfig文件。这甚至可以在链式包括 - 例如〜/ .gitconfig 可以有:

      [include] 
    path = subdir / gitconfig

    subdir / gitconfig 可以有:

      [include] 
    path = nested_subdir / gitconfig

    ...这会导致加载 subdir / nested_subdir / gitconfig p>


  3. 如果git找不到目标文件,它会默默地忽略错误。这似乎是设计。



Possible Duplicate:
Is it possible to include a file in your .gitconfig

With bash and zsh I can source subfiles in order to better organize my config.

Can I do something similar with .gitconfig?

解决方案

(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:

  1. Path expansion, e.g. ~ or $HOME, does not appear to be supported.

  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.

  3. If git can't find the target file, it silently ignores the error. This appears to be by design.

这篇关于我可以从另一个加载一个.gitconfig文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆