Sublime Forum

Bug: Git ignore with Windows file paths

#1

In my local .gitignore file I’m excluding files with backslashes rather than forward slashes (Windows style rather than Linux).

i.e. **\packages doesn’t exclude the folder, but **/packages does. Ideally either path style should work (other clients support it fine)

1 Like

#2

Backslashes are not specified in official git docs https://git-scm.com/docs/gitignore to be valid in path. It seems to be a special handling applied by git for Windows. Committing such a .gitignore will most likely cause issues with the repo when checking it out on other platforms. Won’t probably work with git via WSL as well. Hence I am not sure whether using/supporting it is useful.

0 Likes

#3

Testing Git for windows 2.19, it does not support backslashes as a directory separator in .gitignore files.

Do you know which versions of Git you’ve seen support them?

0 Likes

#4

Yes I can. It is Git for windows 2.19 :slight_smile:

Just added a test\sub\foo.json to a working directory. Calling git status returns test/ as new directory. Adding **\test to the .gitignore file makes git ignore the directory. It does not work with test\ as one might expect, which proofs backslashes are some kind of hack in git for Windows.

Btw.: Backslashes are not supported by the Git Ignore.sublime-syntax for the same reason. Everything followed by a backslash is handled as escaped.

0 Likes