.gitignore不起作用时的解决方法

158 阅读1分钟

我在一次提交之前没有在 .gitignore 声明 .idea ,后来检查重新声明之后再 push 发现并不起作用,以下是解决方法。

    // 1.清除缓存
    git rm -r --cached .

    // 2.将要忽略的文件在 .gitignore 中声明

    // 3.添加文件
    git add .

    // 4.再次提交
    git commit -m 'update .gitignore'
    git push