gitignore 无法忽略库中的 .pyc 文件

gitignore failing to ignore .pyc files in library

我的gitignore有以下几行

__init__.cpython-36.pyc
functions.cpython-36.pyc
.DS_Store
__pycache__
*.pyc

但是我的 git 客户端仍在注册对 pyc 文件的更改

在网上看了之后我就是不明白我的问题是什么。有任何想法吗?让我知道是否需要提供更多信息。谢谢

此文件在您创建 .gitignore 之前已被跟踪。在那里面 如果您需要取消跟踪:

git rm --cached ...

来自man git-rm

--cached

       Use this option to unstage and remove paths only from the
       index. Working tree files, whether modified or not, will be
       left alone.