我这样做:git rm --cached `git ls-files -i --exclude-from=.gitignore` git commit -m 'Removed all files that are in the .gitignore' git push origin master这将删除git忽略中的所有文件/文件夹,省去了手动选择每个文件/文件夹的麻烦这似乎已停止为我工作,我现在这样做: git rm -r --cached . git add . git commit -m 'Removed all files that are in the .gitignore' git push origin master