Juninho Chr Juninho Chr - 2 months ago 7
Git Question

.gitignore is ignoring other directories with the same name

I have a problem in my .gitignore.
I want it to just ignore the 'vendor/' directory, but it is ignoring all directories with that name.

Below is my .gitignore:

.idea/
bin/
vendor/
composer.lock
composer.phar


Below is the result of my 'git status':

Changes not staged for commit:
   (use "git add <file> ..." to update what will be submitted)
   (use "git checkout - <file> ..." to discard changes in working directory)

modified: .gitignore

Not monitored files:
   (use "git add <file> ..." to include what will be submitted)

src/vendor/
tests/src/
vendor/


It is also ignoring 'src/vendor', I do not want that to happen, I want it to ignore 'vendor/'

Answer

From the docs for Git Ignore

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

Try changing vendor/ to /vendor/

Comments