记录下最近遇到不小心提交了node_modules到github的解决办法
参考stackoverflow 以及gitignore使用
- 首先在根目录下的.gitignore中写入node_modules/, 提交时将忽略当前目录以及子目录下的node_modules
touch .gitignore
echo **/node_modules/ >> .gitignore
//**表示任意层级下的node_modules/
- 然后将node_modules从git 追踪中删除
git rm -r --cached node_modules
To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename
- 重新提交,从github中删除所有node_modules
git add . -A
git commit -m "remove node_modules"
git push
网友评论