.gitignore的作用是使得push时忽视.gitignore中的文件 在当前仓库目录下 vim .gitignore 写入你想要忽视的文件 比如 写入*/.txt。这就代表忽视该仓库下所有文件夹中后缀为txt的文件 接下来 git rm -r --cached . git status --ignored git add . git commit -m "add .gitignore" git push