Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the syntax for specifying Windows paths in .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.

like image 983
Scott Wegner Avatar asked Feb 14 '15 21:02

Scott Wegner


People also ask

What is the path of the Gitconfig file?

The system level configuration file lives in a gitconfig file off the system root path. $(prefix)/etc/gitconfig on unix systems. On windows this file can be found at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer.

How do I find my Gitconfig path?

git config --global --edit should tell you the exact location no matter what kind of setup you have--just look at what file comes up in your editor. git config --global --list was also useful for when it doesn't exist as it gave the location of where git is expecting it to be.


1 Answers

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"
like image 68
Scott Wegner Avatar answered Nov 10 '22 06:11

Scott Wegner