为什么不能为我执行`git config`命令的`--includes`键?

时间:2015-07-11 23:17:59

标签: git

我使用来自here的Git-2.4.5.1-4th-release-candidate-64-bit.exe。

我正在学习Git,我正在阅读有关git config命令的文档。我明白这一点:

  

--[no-]includes
在查找值时,请尊重配置文件中的include.*指令。默认为开启。

和此:

  

INCLUDES
  您可以通过设置special来包含另一个配置文件   include.path变量到要包含的文件的名称。该   包含的文件立即展开,就像它的内容一样   在include指令的位置找到。如果是的价值   include.path变量是一个相对路径,该路径被认为是   相对于include指令所在的配置文件   找到。 include.path的值受波形扩展的影响:〜/ is   扩展到$ HOME的值,并将~user /扩展到指定的用户   主目录。请参阅下面的示例。

     

示例

# Core variables
[core]
        ; Don't trust file modes
        filemode = false
# Our diff algorithm
[diff]
        external = /usr/local/bin/diff-wrapper
        renames = true
[branch "devel"]
        remote = origin
        merge = refs/heads/devel
# Proxy settings
[core]
        gitProxy="ssh" for "kernel.org"
        gitProxy=default-proxy ; for the rest
[include]
        path = /path/to/foo.inc ; include by absolute path
        path = foo ; expand "foo" relative to the current file
        path = ~/foo ; expand "foo" in your $HOME directory

我创建了这样的d:\server.gitconfig文件:

[http]
  proxy = http://@proxy2:8080

此外,我添加到C:\Users\Andrey\.gitconfig文件(这与--global密钥相同),例如include组:

[include]
  path = /d/server.gitconfig

但是当我发布命令时

git config --list

git config --includes --list

我看到include.path=/d/server.gitconfig记录而不是http.proxy=http://@proxy2:8080。 此外,当我启动命令

git config http.proxy

git config --includes http.proxy

我没有看到我的http.proxy设置。为什么不发生包括?

1 个答案:

答案 0 :(得分:3)

使用git-for-windows,这只适用于git配置文件中的Windonws样式路径:

onReceive()

请注意将[include] path = c:\\prgs\\server.gitconfig 加倍作为路径分隔符。

然后,立即读取并扩展所包含的配置文件。

这也适用于路径中的空间:

\\

git config --global include.path "c:\prgs\test with space\server.gitconfig" 命令行上不需要\\

这给出了:

git config

[include] path = c:\\prgs\\test with space\\server.gitconfig 文件本身内部不需要双引号)

相关问题