有时候,.gitignore会对部分文件/文件夹失效,大概原因是由于新创建的文件已经出现在git本地仓库的缓存,所以.gitignore就失效了;解决办法就是清空一下git仓库的缓存,重新提交一次就好了
直接在idea的terminal中一次输入一下命令就可以了:
git rm -r --cached .
git add .
git commit -m ‘update .gitignore’
注意:
如果有报错:error: pathspec ‘.gitignore’’ did not match any file(s) known to git.
则到相应项目下.git目录层如下操作:
在gitbash中执行以上三个命令: