Remove .pyc files from Git remote repository

  1. Remove .pyc files using git rm *.pyc. If this not work use git rm -f *.pyc
  2. Commit git commit -a -m 'all pyc files removed'
  3. Push git push
  4. In future commits you can ignore .pyc files by creating a .gitignore file

No, you cannot delete them directly from the BitBucket interface but you can delete them in your local checkout and find ./ -type f -name '*.pyc' -exec git rm {} \; ( or simply git rm each pyc file one by one ). Then commit/push your changes.

Finally, to avoid ever making the same mistake again you may create a file at the root of your repo and name it '.gitignore' with the contents:

*.pyc
*~
*.swp

*~ and ~.swp are other commonly forgotten file types that are often accidentally pushed. See the github doc on gitignore https://help.github.com/articles/ignoring-files (and their repo of .gitignore files for some nice defaults).


git rm *.pyc --cached
git commit -a -m'remove pyc from index'
git push

PS: I see the date of question, but this solution looks better, imho. May be it'll help someone.. .