.gitignore忽略了具有相同名称的其他目录

21 git gitignore

我的.gitignore有问题.我希望它只是忽略'vendor /'目录,但它忽略了具有该名称的所有目录.

下面是我的.gitignore:

.idea/ 
bin/ 
vendor/ 
composer.lock 
composer.phar 
Run Code Online (Sandbox Code Playgroud)

以下是我的'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/ 
Run Code Online (Sandbox Code Playgroud)

它也忽略了'src/vendor',我不希望这种情况发生,我希望它忽略'vendor /'

And*_*w C 33

来自Git Ignore的文档

前导斜杠与路径名的开头匹配.例如,/*.c匹配cat-file.c但不匹配mozilla-sha1/sha1.c.

尝试vendor/改为/vendor/