宁陵视频网站建设西安市建设工程交易中心
前言
新建了一个vitepress 项目 但上传至github的时候不小心把node_modules 上传到仓库中了,于是我重新添加了 .gitignore 然后重新上传项目, 上次成功后却发现 node_modules 在仓库中依然存在
思考
这种情况可能是因为 Git 会继续跟踪已经被提交的文件,即使你在 .gitignore 中添加了 node_modules
解决
1.删除已经被 Git 跟踪的 node_modules 目录:
git rm -r --cached node_modules
2.确保 .gitignore 文件已正确配置:
确保 .gitignore 中已经正确包含了 node_modules:
node_modules
3.重新提交:
git add .
git commit -m "Remove node_modules from version control"
git push
这几步完成后,node_modules 就不会再出现在仓库中了。如果你再做一些修改并推送,Git 应该会忽略 node_modules 文件夹了。
