原因 因为新建的文件会在git中有缓存,纳入了版本管理中,所以.ignore没有生效,所以要清除缓存 解决方案 执行 git rm -r --cached . 再执行 git add . .ignore生效