.gitignore文件不启作用

问题:
.gitignore只能忽略那些原来没有被track(之前没有add过)的文件,
如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的。

解决方案:
先把本地缓存删除(改变成未track状态),然后再提交:
git rm -r --cached target
git rm -r --cached .idea

    报错加 -f
    the following file has staged content different from both the file and the HEAD:.idea/.gitignore
    (use -f to force removal)
    git rm -r -f --cached .idea

你可能感兴趣的:(.gitignore文件不启作用)