更改.gitignore后,要重新更新git的仓库索引。 git rm -r --cached . 将仓库中的index递归删除 重新添加仓库索引 git add --all 提交 git commit -am "update .gitignore"