首页 > 解决方案 > 推送 node_modules 但无法弄清楚如何删除

问题描述

我将节点模块推送到 GitHub,然后意识到我没有.gitignore.

我添加了,gitignore但它没有解决问题。
我在这里找到了答案,说要从缓存中删除它git rm -r --cached node_modules,但这不起作用,因为它说它找不到该文件,我仍然可以在我的仓库中看到它。

我的文件结构是 repo,然后是一个dev包含在其中的文件夹node_modules,以及我编写的所有其他代码。
位于文件夹.gitignore之外,位于dev文件旁边README

我是否需要提供.gitignorea 路径来查找 a 之类的模块./node_modules

标签: node-modulesgitignore

解决方案


gitignore 位于自述文件旁边的 dev 文件夹之外

然后,它应该包括:

dev/node_modules/

那将忽略dev/node_modules文件夹及其内容。

检查(git rm --cached dev/node_modules从你的仓库的根文件夹完成后):

git check-ignore -v -- dev/node_modules/afile

(在该文件夹内的一个现有文件上测试它dev/node_modules/


推荐阅读