I built a web app on a my local win7 machine. I did it with pycharm and used git as version control. I'm a total git novice.
I put the repository on github so that I could stage the webapp to my pythonanywhere server.
On pythonanywhere side, I did some small edits to various files. I wanted to commit these changes back to the repository.
(udemy) 10:44 ~/keystone (master)$ git commit -m "got it running on pythonanywhere staging"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified: keystone/settings/base.py
modified: keystone/settings/local_postgres.py
modified: keystone/settings/staging_straits.py
deleted: p0150_1.pdf
Untracked files:
crapboard/__pycache__/
crapboard/migrations/__pycache__/
crapboard/templatetags/__pycache__/
keystone/__pycache__/
keystone/settings/__pycache__/
no changes added to commit
There were three modified files and one deletion that I wanted to commit to the repository.
so I did
(udemy) 14:03 ~/keystone (master)$ git add --all
(udemy) 14:03 ~/keystone (master)$ git commit -m "staged to pythonanywhere"
[master ac6bb7e] staged to pythonanywhere
27 files changed, 23 insertions(+), 115 deletions(-)
create mode 100644 crapboard/__pycache__/__init__.cpython-36.pyc
create mode 100644 crapboard/__pycache__/admin.cpython-36.pyc
create mode 100644 crapboard/__pycache__/apps.cpython-36.pyc
create mode 100644 crapboard/__pycache__/forms.cpython-36.pyc
create mode 100644 crapboard/__pycache__/models.cpython-36.pyc
create mode 100644 crapboard/__pycache__/pdf_views.cpython-36.pyc
create mode 100644 crapboard/__pycache__/urls.cpython-36.pyc
create mode 100644 crapboard/__pycache__/views.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0001_initial.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0001_squashed_0005_auto_20170921_2154.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0002_auto_20170909_1137.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0003_auto_20170912_2029.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0004_problem_author.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0005_auto_20170921_2154.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/__init__.cpython-36.pyc
create mode 100644 crapboard/templatetags/__pycache__/__init__.cpython-36.pyc
create mode 100644 crapboard/templatetags/__pycache__/crapboard_filters.cpython-36.pyc
create mode 100644 keystone/__pycache__/__init__.cpython-36.pyc
create mode 100644 keystone/__pycache__/urls.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/__init__.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/base.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/settings_secret.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/staging_straits.cpython-36.pyc
rewrite keystone/settings/staging_straits.py (65%)
delete mode 100644 p0150_1.pdf
Argh. It committed all these __pycache__
directories too.
I'm guessing this happened because I should have made some kind of global/general .gitignore file on my pythonanywhere server?
So questions:
1) how do I get rid of this pycache stuff from my repository permanently 2) how do I prevent my pythonanywhere server from trying to add that stuff to my repository in the future -- I do not have this issue with pycharm/local machine -- it ignores those files.
According to git docs, it is simplely to add to ~/.gitignore the following:
**/__pycache__
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".