在 .gitconfig 中指定 Windows 路径的语法是什么?

What is the syntax for specifying Windows paths in .gitconfig?

我正在尝试使用 include.path config described here,但我似乎无法在 Windows 上找到正确的路径语法。

我当前的.git配置:

[include]
    path = 'D:\Scott\Shared\config\common.gitconfig'

但是 git 抱怨:fatal: bad config file line 2 in C:\Users\Scott/.gitconfig

Windows 的转义路径的正确方法是什么?注意:我使用的是 Powershell 中的 git 而不是 git bash.

根据 git bash 中 pwd 的输出,我推测它可能是

/d/Scott/Shared/config/common.gitconfig

好的,明白了。诀窍是:

  1. 用双引号引起来
  2. 将反斜杠转换为正斜杠。
  3. 绝对路径以盘符 + 冒号开头

所以上面的正确版本是:

[include]
    path = "D:/Scott/Shared/config/common.gitconfig"