在git bash中逐条执行如下命令:
$ add .gitignore
#查看状态,是否忽略了指定的文件?
$ git status --ignored #查看状态,包括忽略的文件

#让其对已经跟踪的文件也起作用
$ git rm -r --cached . #清除缓存 -r 表示递归删除(如果有文件夹的话) . 表示所有文件

#查看一下具体效果
$ git status --ignored
$ git add . #重新trace file
$ git commit -m “update .gitignore” #提交和注释

更多推荐