gitignore不起作用

gitignore只对未跟踪的文件起作用。

对已提交的文件,要忽略,可以用以下方法:

例如config.json这个文件

1. gitignore添加config.json

2. 执行命令,从缓存忽略

rm config.json
git rm --cached config.json 
git add config.json 
git commit -m "ignore config.json"
git push

 

 
 
 
参考:https://zhuanlan.zhihu.com/p/270144760

posted @ 2021-09-08 17:04  全玉  阅读(80)  评论(0编辑  收藏  举报