场景是这样的,我的同事已经将 node_modules 文件夹从他的机器推送到远程仓库。
在我的机器上,我运行了“npm_install”来安装所有必需的依赖项。现在,当我尝试与远程仓库同步以获取新更改时。我收到这条消息:
Cannot pull because there are uncommitted changes.
Commit or undo your changes before pulling again. See the Output window for details.
在 Changes 选项卡中:包含我的 node_modules 目录。所以,我需要忽略它。
我尝试了以下方法:
- 添加到 tsconfig.ts 中:"exclude": ["node_modules"]
- 将“node_modules”添加到 gitignore
注意: node_modules 目录位于 Repo\Comaps\Compas_ng\Compas_ng 文件夹中,该文件夹是解决方案中的 Web 应用程序。 gitignore 文件位于父目录 Repo\Compas 中。
但是,当再次同步时,node_modules 仍然出现在更改选项卡中。
我应该怎么做才能解决这个问题?以及为什么这些选项对我不起作用。
最佳答案
您需要清理 node_modules 文件夹的缓存:
git rm --cached -r node_modules
关于Git 无法忽略 Visual Studio 中的 node_modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40140251/