.gitinore配置失效问题

问题:在.gitinore中配置忽略项,配置失效

原因:新增加忽略项已经提交过,在暂存区或分支上被版本控制

解决:删除暂存区分支上的文件(本地需要使用, 只是不希望这个文件被版本控制), 可以使用

git rm --cached file_path
git commit -m 'delete remote somefile'
git push
example:
git rm --cached tests_outputs/*
git commit -m '忽略tests_outputs文件夹下的提交'
git push
原文地址:https://www.cnblogs.com/xsnow/p/10518032.html