Reputation: 1221
in my Django project,i have already .gitignore file in root as well in django project but when i fire git status
or git add .
It adding all __pycache__
db.sqlite3
in repository. i need to remove those two things from my project. please help.!
I tried all things like
*.sqlite3
,mom/*.sqlite3
,mom/db.sqlite3
anddb.sqlite3
in my both.gitignore
file respectively. But anything not work in any directory.
here is my main git ignore file .gitignore
media
*.sqlite3
**/__pycache__/**
*.pyc
here is my another git ignore file .gitignore
media
db.sqlite3
**/__pycache__/**
*.pyc
I also tried many possibilities from online resources but anything not working
file structure
MOM-PROJECT(local Repo)
|
├───MOM (main project)
| ├───media
| │ └───media
| ├───MOM
| │ ├───migrations
| │ └───templatetags
| ├───userprofile
| │ └───migrations
| │ └───__pycache__
| ├───templates
| │ ├───MOM
| │ ├───userprofile
| │ └───base.html
| ├───manage.py
| ├───requirements.txt
| ├───db.sqlite3
| └───.gitignore [another created after main]
|
├───README.md
├───.git
└───.gitignore [Main]
list adding file of git add command
modified: .gitignore
new file: mom/.gitignore
new file: mom/db.sqlite3
modified: mom/meeting/admin.py
modified: mom/meeting/views.py
modified: mom/static/js/meetingtext.js
...
Umm Actually first i created .gitignore
file in at main folder where .git
folder(in project
) exist. my media folder automatically removed and that worked fine. but when i added mom/db.sqlite3
or *.sqlite3
in main .gitignore
it's not ignoring therefore i created another .gitignore
file inside my project folder where db.sqlite3
is exist. but that also not ignoring my db.sqlite3
file
please suggest me what i need to do. please don't suggest me to use Smart-Git or any other GUI option. right now i m learning phase so i need all thing over commandline
Upvotes: 3
Views: 2999
Reputation: 176
I had the same issue but found out that my problem was that I had already tracked and committed the db.sqlite3 file in previous commit, which made it impossible for git to ignore when I later added it to the .gitignore.
I think this is not your case but maybe it can give you some hints towards a solution.
To untrack the file without deleting the local file I used:
git rm -r --cached db.sqlite3
After this, the .gitignore is doing the job as intended.
Upvotes: 8
Reputation: 303
Remove the *s.
If you specifically want to ignore the pycache and db.sqlite3 files, just add
__pycache__/
db.sqlite3
to your .gitignore file. Alternatively search for django .gitignore
files and sample from there.
If you want to know in depth on the gitignore file check out https://git-scm.com/docs/gitignore
Upvotes: 0