Can I load one .gitconfig file from another? [duplicate]

若如初见. 提交于 2020-01-01 08:42:15

问题


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?


回答1:


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




回答2:


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

$GIT_DIR/config

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".



来源:https://stackoverflow.com/questions/4030540/can-i-load-one-gitconfig-file-from-another

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!