Search code examples
pythondjangogitpycharmgitkraken

Django settings.cpython-36.pyc not ignored by gitignore


The file in my application settings.cpython-36.pyc is not being ignored even though I have added it to the .gitignore file.

My gitignore code:

*.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

This line LearnDjango/__pycache__/ in the gitignore file ignores the other .cpython-36.pyc files but not settings.cpython-36.pyc

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

P.S I am new to Django and git.


Solution

  • I was facing the same problem.

    1. First, make sure that you don't have any changes to commit;
    2. Edit or create your .gitignore and put the follow code:

    *.log

    *.pot

    *.pyc

    */*/*/__pycache__/

    */*/__pycache__/

    */__pycache__/

    1. Save -> git add . -> git commit
    2. 'Clean Git Hub Cache' for your repo:

    git rm -rf --cached .

    git add .

    1. Commit and it's done!

    I hope that this can help you.