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

Sco*_*ner 7 windows git powershell path

我正在尝试使用include.path此处描述配置,但我似乎无法在Windows上找到正确的路径语法.

我目前的.gitconfig:

[include]
    path = 'D:\Scott\Shared\config\common.gitconfig'
Run Code Online (Sandbox Code Playgroud)

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

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

Sco*_*ner 8

好吧,想通了.诀窍是:

  1. 用双引号括起来
  2. 将反斜杠转换为正斜杠.
  3. 绝对路径以驱动器号+冒号开头

所以上面的正确版本是:

[include]
    path = "D:/Scott/Shared/config/common.gitconfig"
Run Code Online (Sandbox Code Playgroud)