2015-07-11 86 views
2

我使用來自here的Git-2.4.5.1-4th-release-candidate-64-bit.exe。爲什麼我不能爲`git config`命令的`--includes`鍵操作?

我正在學習Git,我正在閱讀有關git config命令的文檔。我看到這一點:

--[no-]includes
尊重include.*指令在配置文件中查找值時。默認爲開啓。

這:

INCLUDES
可以包括從另外一個配置文件由特殊 include.path變量設置爲文件的名稱包括在內。 包含的文件立即展開,就好像它的內容在include指令的位置找到了 一樣。如果include.path變量的值是相對路徑,則相對於包含指令爲 的配置文件,該路徑被認爲是 。 include.path的值受波形擴展的影響:〜/爲 擴展到$ 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設置。爲什麼不發生包括?

回答

3

隨着git-for-windows,這僅適用於在混帳配置文件Windonws風格的路徑:

[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 

(沒有雙引號需要裏面的gitconfig文件本身)

+0

謝謝, @VonC。我怎樣才能寫一個文件哪個目錄的名稱有空格?我試過這個:'git config --global --add「D:\\ 123 456 \\ 78 90 \\ server.gitconfig」'但它不起作用。這也是:'git config --global --add \「D:\\ 123 456 \\ 78 90 \\ server.gitconfig \」' –

+0

@Bush我編輯了答案來說明它可以使用路徑包括它的空間。 – VonC

+0

是的,謝謝! –

相關問題