python - Django settings.cpython-36.pyc 没有被 gitignore 忽略

标签 python django git pycharm gitkraken

我的应用程序 settings.cpython-36.pyc 中的文件没有被忽略,即使我已将它添加到 .gitignore 文件。

我的 gitignore 代码:

*.log
*.pot
*.pyc
.idea
LearnDjango/__pycache__/
venv/
/LearnDjango/settings.py
LearnDjango/__pycache__/settings.cpython-36.pyc

Gitkraken view, you can see it still picks it up

gitignore 文件中的这一行 LearnDjango/__pycache__/ 会忽略其他 .cpython-36.pyc 文件,但不会忽略 settings.cpython-36.pyc

View of __pycache__ folder, the 1st and 3rd files are ignored but not the 2nd

附言 我是 Django 和 git 的新手。

最佳答案

我遇到了同样的问题。

  1. 首先,确保您没有任何更改要提交;
  2. 编辑或创建您的 .gitignore 并放入以下代码:

*.log

*.pot

*.pyc

*/*/*/__pycache__/

*/*/__pycache__/

*/__pycache__/

  1. 保存 -> git 添加。 -> git 提交
  2. 为您的存储库“清理 Git Hub 缓存”:

git rm -rf --cached .

git add .

  1. 提交并完成!

希望对您有所帮助。

关于python - Django settings.cpython-36.pyc 没有被 gitignore 忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48072655/

相关文章:

python - 使用正则表达式匹配多种日期/时间戳

python - 如何在vim的python模式下关闭运行窗口

python - Django 、Python : Best way to parse a CSV and convert to Django model instances

git - 防止 git merge 确认提交消息

python - 如何在python中从多个图像创建一个psd分层文件

python - RGB色彩校正

javascript - 无法访问保存在 Javascript 代码中的存储桶中的图像

python - 使用下划线忽略传递给我们不需要的函数的值是一种好习惯吗?

git - 我怎样才能修改以前的 git commit

git - GIT repo 中每个开发人员的分支