Git 无法忽略 Visual Studio 中的 node_modules

标签 git visual-studio visual-studio-2015 npm gitignore

场景是这样的,我的同事已经将 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 目录。所以,我需要忽略它。

我尝试了以下方法:

  1. 添加到 tsconfig.ts 中:"exclude": ["node_modules"]
  2. 将“node_modules”添加到 gitignore

enter image description here

注意: node_modules 目录位于 Repo\Comaps\Compas_ng\Compas_ng 文件夹中,该文件夹是解决方案中的 Web 应用程序。 gitignore 文件位于父目录 Repo\Compas 中。

enter image description here

但是,当再次同步时,node_modules 仍然出现在更改选项卡中。

我应该怎么做才能解决这个问题?以及为什么这些选项对我不起作用。

最佳答案

您需要清理 node_modules 文件夹的缓存:

git rm --cached -r node_modules

关于Git 无法忽略 Visual Studio 中的 node_modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40140251/

相关文章:

node.js - 私有(private)依赖项的 npm 安装不起作用,但克隆可以

git - 要推送到 git 的 Carthage 文件列表

c# - 如何从 VS2015 中引用不同的 mscorlib.dll?

c++ - 更改默认代码 Visual Studio 2015 Community

visual-c++ - Windows 7 专业版 : Fails to install Visual C+ +'s "Common Tools for Visual C++ 2015"feature

javascript - 如何从 visual studio 项目中排除文件/文件夹?

javascript - 开发相互依赖的 npm 包的最佳工作流程

ruby-on-rails - git-gui--askpass : No such file or directory

c++ - Visual Studio 非托管 C++ 智能文件资源管理器

c - 学习C——想用visual studio