Search code examples
gitgitignore

Why git status shows files under /vendor dir?


Running command

git status

in root of laravel project I see a lot of messages, like :

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
...
deleted:    vendor/phpdocumentor/reflection-common/phpstan.neon
deleted:    vendor/phpdocumentor/reflection-common/psalm.xml
...
deleted:    vendor/phpdocumentor/reflection-docblock/.dependabot/config.yml
deleted:    vendor/phpdocumentor/reflection-docblock/.github/workflows/push.yml
deleted:    vendor/phpdocumentor/reflection-docblock/Makefile
deleted:    vendor/phpdocumentor/reflection-docblock/composer-require-config.json
git add  vendor/phpdocumentor/reflection-docblock/composer.json
deleted:    vendor/phpdocumentor/reflection-docblock/phive.xml
deleted:    vendor/phpdocumentor/reflection-docblock/phpcs.xml.dist
deleted:    vendor/phpdocumentor/reflection-docblock/phpstan.neon
deleted:    vendor/phpdocumentor/reflection-docblock/psalm.xml
git add  vendor/phpdocumentor/reflection-docblock/src/DocBlock/StandardTagFactory.php
git add  vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Deprecated.php
git add  vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/InvalidTag.php
git add  vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Since.php
git add  vendor/phpdocumentor/type-resolver/composer.json
git add  vendor/phpdocumentor/type-resolver/src/Types/Compound.php
git add  vendor/phpoffice/phpspreadsheet/CHANGELOG.md
git add  vendor/phpoffice/phpspreadsheet/composer.json
git add  vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Calculation.php
git add  vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Category.php

I wonder why so, as in root .gitignore I have:

/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea


/__DOCS/
/__SQL/


package-lock.json
package.json


.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

composer.lock
1.txt

I expected that line

/vendor

made all changes in automatically generated /vendor dir invisible for git. And it worked in this way last time and seems I have not modified root .gitignore last monthes Could you say what happened and which is valid format of root .gitignore ?

Thanks!


Solution

  • Git is tracking your vendor directory. Try to remove that from from index.

    To stop tracking you need to remove the folder from index.

    git rm -r --cached vendor

    This will not delete anything that is saved in the working directory.