是否可以在.gitconfig中包含一个文件 [英] Is it possible to include a file in your .gitconfig

查看:139
本文介绍了是否可以在.gitconfig中包含一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在包含github设置的.gitconfig文件中包含一个文件 - 这可能吗?

我可以这样做:

  [core] 
include = / path / to / file

.gitconfig

 支持此语法。 code> [include] 
path = / path / to / file

请参阅此处详细介绍了git变更及其边缘案例。



顺便提一下,有一些值得指出的细节:


  1. 环境变量扩展,例如不支持 $ HOME 。 (扩展名为出现在Git 1.7.10.2中。)

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

      [include] 
    path = subdir / gitconfig

    subdir / gitconfig 可以有:

      [include] 
    path = nested_subdir / gitconfig

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

  3. 如果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:

  1. Environment-variable expansion, e.g. $HOME, is not supported. (Expansion of ~ appeared in Git 1.7.10.2.)

  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天全站免登陆