在使用github时,有可能在提交.gitignore文件后,还存在遗漏的文件没有被忽略。故需要添加这些文件到.gitignore中,然后根据下面的操作,可以让文件生效。
# update .gitignore
$ git status --ignored #查看忽略的文件
$ git rm -r --cached . #递归清除缓存 -r 表示递归删除(如果有文件夹的话) . 表示所有文件
#查看一下具体效果
$ git add . #重新添加文件
$ git commit -m "[update] update file .gitignore" #提交和注释
$ git push #提交到远程库