Using .gitignore with *.pyc in subfolders
You should not need the **/
:
__pycache__/ *.pyc
That should be enough.
See for instance gitignore.io/python.
Note the practice of adding a trailing /
to ignore specifically a folder.
Use git check-ignore -v -- afile
(that I mentioned in Sept. 2013, with Git 1.8.2+) to check which rule ignores a file.
If the folder was already tracked:
git rm --cached -r __pycache__/
André Duarte adds in the comments:
After adjusting
gitignore
, I had to do this for every file, so I callawk
for help:
git status | grep pycache | awk '{print $3}' | xargs git reset HEAD