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

与世无争的帅哥 提交于 2019-12-19 17:33:14

问题


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.


回答1:


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"



回答2:


Based on output of pwd in git bash, I would speculate it is probably

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


来源:https://stackoverflow.com/questions/28520565/what-is-the-syntax-for-specifying-windows-paths-in-gitconfig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!