我正在尝试将我的项目推送到 GitHub 和 Heroku。因为我在我的应用程序中使用 Node.js,所以我有文件夹 node_modules。在提交之前,我创建了一个名为 .gitignore
的文件来忽略 Node.js 模块。
在文件中,我添加了文件夹 node_modules 并尝试从命令行/终端推送到 GitHub 存储库。我没想到 Node.js 模块会被推送,但它们最终出现在存储库中。有没有我必须遵循的方法?
这是我解决问题的方法
- $ git rm -r --cached node_modules
将文件夹 node_modules/ 添加到您的 .gitignore 文件:
- $ git commit -m "remove the ignored directory node_modules"
然后
- $ git push origin master
之后,如果您刷新 GitHub 页面,您将看到 node_modules 文件夹消失了。
最佳答案
node_modules
文件夹应该添加到 .gitignore
文件中。
首先,摆脱你的node_modules
:
$ git rm -r --cached node_modules
$ git commit -m "remove node_modules"
然后, push 你的改变
$ git push origin master
刷新页面以查看所需的效果。
关于git - 推送到 GitHub 的 Node.js 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44168609/