Accidentally, I have pushed the .pyc files to the master repository. Now I want to delete them but I can´t do it. Is there any way to remove them directly from the Bitbucket sit
Because in default Bitbucket, there is no .gitignore file in the repo,so you can do :
Go to the PyDev Package Explorer of your project and do:
right click + Pydev / Remove *.pyc *.pyo and *$py.class File
a window will popup telling you how many files have been deleted.
Optional: Commit your change to the team/server:
In the commit window you shouldn't see any .pyc available to add as we deleted them. Also if you committed such files before then you should be able to commit their "deletion" now.
===> Your local and server repository are now free of *.pyc *.pyo and *$py.class 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.. .
A one-liner for fun:
git status | grep pyc | sed -e 's/ new file: //g' | xargs -I {} git rm --cached {}
.pyc
files using git rm *.pyc
. If this not work use git rm -f *.pyc
git commit -a -m 'all pyc files removed'
git push
.pyc
files by creating a .gitignore
file