user1750290
user1750290

Reputation: 125

Git - .gitignore Ignores folders throughout repo

Is it possible to have

foo/ 

in .gitignore but then not to ignore

 bar/foo

without adding

 !bar/foo

to .gitignore

Upvotes: 3

Views: 64

Answers (1)

Femaref
Femaref

Reputation: 61437

Use /foo/ instead, / matches the beginning of the path. From the gitignore manpages:

A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".

Upvotes: 9

Related Questions