Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I cannot ignore pycache and db.sqlite on Django even though it refers them at .gitignore

I'd like to ignore the changes of pycache and db.sqlite of Django project. I refer them at .gitignore,however git catches the variation of them. Could you tell me what is problem if you know it? I attached my .gitignore at the end of sentence.

enter image description here .gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
media/
settings.py

.idea/

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
.venv/
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# Database stuff
*.sqlite3
migrations/
db.sqlite3

# Atom config file
.editorconfig

# Other unwanted stuff
.idea
.DS_Store
.DS_STORE
like image 464
Toshi Avatar asked Oct 25 '16 03:10

Toshi


2 Answers

As follows, I've solved the problem.

git rm -r --cached .   # will delete whole git history, use with caution
git add .
git commit -m
git push ~
like image 56
Toshi Avatar answered Oct 12 '22 11:10

Toshi


As an alternative to git rm -r --cached . in the @lalala's answer, you can target the files you actually want to delete from the cache using git rm --cached <filename>. This is generally more desirable since it leaves the other files untouched. You may use metacharacters like *.sqlite in place of <filename> to target even more files.

like image 25
KayO Avatar answered Oct 12 '22 11:10

KayO