在.gitconfig中指定Windows路径的语法是什么? [英] What is the syntax for specifying Windows paths in .gitconfig?

查看:258
本文介绍了在.gitconfig中指定Windows路径的语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我目前的.gitconfig:

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

但git抱怨:致命:在C:\ Users \Scott / .gitconfig



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

解决方案

好的,找到了解决方法。诀窍是:


  1. 用双引号环绕

  2. 将反斜杠转换为正斜杠。
  3. li>
  4. 以绝对路径的驱动器号+冒号开头

所以上面的正确版本是:

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


I'm trying to use the include.path config described here, but I can't seem to find the correct path syntax on Windows.

My current .gitconfig:

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

But git complains: fatal: bad config file line 2 in C:\Users\Scott/.gitconfig

What's the proper way to escape paths for Windows? Note: I'm using git from Powershell and not git bash.

解决方案

Ok, figured this out. The trick is:

  1. Surround in double-quotes
  2. Convert backslashes to forward slashes.
  3. Begin with drive letter + colon for absolute paths

So the correct version of the above is:

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

这篇关于在.gitconfig中指定Windows路径的语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆