为什么 git 状态显示 /vendor 目录下的文件?

Why git status shows files under /vendor dir?

运行 命令

git status

在 laravel 项目的根目录中,我看到很多消息,例如:

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

我想知道为什么会这样,就像在 root 中一样。git忽略我有:

/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

我预计那行

/vendor

使自动生成的 /vendor 目录中的所有更改对 git 不可见。 上次它以这种方式工作,似乎我没有修改 root 。git忽略上个月 你能说说发生了什么吗,哪个是 root 的有效格式 .gitignore ?

谢谢!

Git 正在跟踪您的 vendor 目录。尝试从索引中删除它。

要停止跟踪,您需要从索引中删除该文件夹。

git rm -r --cached vendor

这不会删除保存在工作目录中的任何内容。