11

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.

phd
  • 82,685
  • 13
  • 120
  • 165

3 Answers3

23

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.

  • Ahhh... as stated by the user Ahmad in this post, you must to clean the github cache also: https://stackoverflow.com/a/25436481/4252612 – William Zimmermann Feb 21 '18 at 14:34
  • After adjust gitignore, I had to do this for every file, so I call awk for help: "git status | grep pycache | awk {'print $3'} | xargs git reset HEAD" – André Duarte Oct 04 '19 at 14:23
0

add these to your gitignore and try it will work

*.pyc
*/*/*/__pycache__/
*/*/__pycache__/
*/__pycache__/
Midhun Mohan
  • 552
  • 5
  • 18
0

I recommend you use this in your project.django project sample .gitignore file

Abdur Rehman
  • 114
  • 3
  • 11