撤消提交的node_modules

2018-12-05  本文已影响0人  Shaw007

记录下最近遇到不小心提交了node_modules到github的解决办法
参考stackoverflow 以及gitignore使用

  1. 首先在根目录下的.gitignore中写入node_modules/, 提交时将忽略当前目录以及子目录下的node_modules
touch .gitignore
echo **/node_modules/ >> .gitignore
//**表示任意层级下的node_modules/
  1. 然后将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

  1. 重新提交,从github中删除所有node_modules
git add . -A
git commit -m "remove node_modules"
git push
上一篇 下一篇

猜你喜欢

热点阅读