Ignore .pyc files in Subversion

Subversion allows you to exclude certain files using regular expressions. This needs to be applied to each directory individually. So, if you add a new directory I think you will need to run the command again. To apply the svn:ignore property to your project you just need to do two things:

Create a file (.svnignore) with the regular expressions


Run svn propset on the project

svn -R propset svn:ignore -F .svnignore .

-R indicates that you are doing this recursively so all the directories ignore these.
-F indicates the file we just created with the regular expressions.

EDIT 5/27/08:
If you’ve already got yourself into the mess of versioning your compiled files, then you might want to do a few things.
1) Revert all the .pyc files (you can always recompile them). You don’t want there to be any local changes when you try to delete them:
find -name "*.pyc" -exec svn revert {} \;
2) Delete all the .pyc files using `svn delete`:
find -name "*.pyc" -exec svn delete {} \;
3) Finally recompile and re-run the svn ignore code above


8 responses to “Ignore .pyc files in Subversion

  1. Pingback: Starting a new Django Project with Versioning « Pandemonium Illusion

  2. Apparently .pyc is ignored by default in the new Subversion.

  3. I hope you realize that *.pyc is not a regular expression. To write the same thing with a regular expression you would write the following:


    I came here searching for a way to use regular expressions in a .svnignore file similarly to how I do with mercurial. I’m beginning to think I won’t find what I’m looking for.

  4. Thanks a lot – it helped me to configure Coda properly.

  5. The command should be:

    find ./ -name “*.pyc” -exec svn revert {} \;

    It was missing a path.


  6. Pingback: how to ignore .pyc in svn (or .class whatever) | Dev Harb

  7. Isaac, the “find” command does not require a path in modern versions of Unix; it assumes the current directory “.” if the command name is immediately followed by predicates.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s