代码之家  ›  专栏  ›  技术社区  ›  John Bachir

我可以从另一个加载一个.gitconfig文件吗?[副本]

  •  10
  • John Bachir  · 技术社区  · 14 年前

    可能重复:
    Is it possible to include a file in your .gitconfig

    使用bash和zsh,我可以为子文件提供源代码,以便更好地组织配置。

    .gitconfig ?

    2 回复  |  直到 8 年前
        1
  •  14
  •   Mike Morearty NiCk Newman    13 年前

    (2012年3月)看来这很快就有可能实现了——git 1.7.10将在 .gitconfig :

    [include]
        path = /path/to/file
    

    here

    顺便说一下,有几个微妙之处值得指出:

    1. 路径扩展,例如。 ~ $HOME

    2. 如果指定了相对路径,则它是相对于.gitconfig文件的 [include] ~/.gitconfig 可以有:

      [include]
          path = subdir/gitconfig
      

      subdir/gitconfig

      [include]
          path = nested_subdir/gitconfig
      

      ... 会导致 subdir/nested_subdir/gitconfig

    3. 如果git找不到目标文件,它会自动忽略错误。这似乎是故意的。

        2
  •  5
  •   Community CDub    8 年前

    Mike Morearty answer (我投了赞成票),git 1.7.10+将支持此功能。


    原答案(2010年10月):

    目前,没有。

    Is it possible to include a file in your .gitconfig ,您已经有3个单独的gitconfig用于组织设置:

    $GIT_DIR/config
    

    ~/.gitconfig
    

    用户特定的配置文件。也称为“全局”配置文件。

    $(prefix)/etc/gitconfig
    

    系统范围配置文件

    配置文件包含在2010年5月讨论过 first patch was written 作者:var Arnfjr°Bjarmason,但我看不到最新的一个补丁” what's cooking in Git ".