.gitignore下面制定了*.pyc但是无效?

我在git的根目录下面新建了一个.gitignore文件,然后添加了以下的内容

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

但是如果我现在修改了一个.py文件,编译后用git status查看

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   views.py
    modified:   views.pyc

no changes added to commit (use "git add" and/or "git commit -a")

请问应该怎么解决这个问题,让git忽视.pyc文件的修改

阅读 14k
4 个回答

忽略已提交到版本的文件
1.git rm -r --cached file_name/dir
2.添加到.gitignore中
3.提交、推送

看日志是已经提交过.pyc,把.pyc在git上删掉即可

你添加了.gitignore文件以后,要把它提交到Git.

新版本的GIT一直不支持

  • 已经加入库的文件,被.gitignore忽略

  • 只能先删除了,再被忽略

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题