composer 模块已 git 修改但未在 git 上暂存

composer module it is git modified but it is not staged on git

我已经使用 composer 开始了一个新项目。该项目使用 git.

进行版本跟踪

问题是我已经安装了组件 "zendframework/zend-session": "^2.7",现在当我尝试执行 git add vendor/zendframework/zend-session 然后 运行 git status 我得到以下信息结果:

On branch feature/install-session-manager
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

        modified:   vendor/zendframework/zend-session (modified content)

no changes added to commit (use "git add" and/or "git commit -a")

注意:当然,我没有修改文件夹中文件的代码vendor/zendframework/zend-session

有谁知道我最终如何才能在我的 git 存储库中进行此修改?

您需要 - 这是一个很好的做法 - 将 vendor 文件夹添加到 .gitignore

这样每个开发人员都可以拥有不同的供应商本地版本,并且您不需要 store/retrive 将它们添加到您的 git 存储库中

要将其添加到 .gitignore,只需将字符串 vendor 放入文件

要取消跟踪现在位于 .gitignore 下的以前的文件,只需 运行

git rm -r --cached .