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