Baruch
Baruch

Reputation: 21548

understanding gitignore with subdirs

If I have the following directory layout:

/
 - a
   - b
     - c.txt

and the following .gitignore

b/

it will match (i.e. ignore) the file, but if the .gitignore is

b/*

it won't?

Upvotes: 2

Views: 72

Answers (1)

bk2204
bk2204

Reputation: 76964

This is correct. Directory separators at the end of a path don't cause it to be anchored to a particular location, but directory separators at the beginning or in the middle will cause it to be anchored to the directory in which the .gitignore file is located.

From gitignore(5):

If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.

Upvotes: 3

Related Questions