Akhilesh Shiuram
Akhilesh Shiuram

Reputation: 113

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.

Upvotes: 11

Views: 9966

Answers (3)

William Zimmermann
William Zimmermann

Reputation: 916

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.

Upvotes: 24

Abdur Rehman
Abdur Rehman

Reputation: 114

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

Upvotes: 0

Midhun Mohan
Midhun Mohan

Reputation: 572

add these to your gitignore and try it will work

*.pyc
*/*/*/__pycache__/
*/*/__pycache__/
*/__pycache__/

Upvotes: 0

Related Questions