I\'m trying to understand more clearly the .gitignore
syntax, and in particular as far as https://github.com/github/gitignore gitignores are concerned.
You've answered your own question entirely. If you look at the github/gitignore repo more closely, you'll see most files use inconsistent rules about how patterns are written; it's very likely most were contributed by people who didn't bother to read the documentation nor test things out as you did.
So if that helps: You're right, be confident.
If you see mistakes in collaborative projects such as this, don't hesitate to contribute your knowledge. There's even some precedent if you need to build up your confidence further.
Just wanted to summarize for possible quick future reference -- the leading slash anchors the match to the root. Thus, in the example below, without the slash, the wildcard would also exclude everything within foo because it would take *
and move recursively down the tree. However, with /*
, it excludes everything except folder foo and its contents:
$ cat .gitignore
/*
!/foo