We just got our servers set up with SVN which works great. Wordpress upgrades and plugin installations are managed manually, which all goes through SVN as well, but I can't work out a good way to version control upload directories.

The best solution I can think of is to periodically go into the folders, look through the images to make sure they are legitimate (no self-unpacking shell scripts, etc) and commit them... either that or svn:ignore the entire folder.

Is there a better way to do this? All the discussion I can find on Google has to do with using SVN for Wordpress installs, not dynamically managed assets.

1 Answer 1


You could hook into the action add_attachment and perform an SVN commit.

add_action( 'add_attachment', 'svn_commit_attachments' );

function svn_commit_attachments( $attachment_ID )
    // collect data about the attachment, for example its path, the user and so on.
     shell_exec ( '$ svn commit -m "$user added file $filename."' )
  • This is certainly an option... I wonder how difficult it would be to write a plugin so users could do a "verification" commit. Part of the reason we moved to SVN was to catch malicious changes made on our servers, so having uploads automatically committed scares me a bit. I'm gonna play with this snippet and see what I can come up with. Apr 23, 2013 at 23:23
  • @kristinachilds This is just a rough draft. If you had used Git you could add those uploads to the stage. But as far as I’m aware there is no such concept in SVN.
    – fuxia
    Apr 23, 2013 at 23:25
  • This whole version control concept is new to me. Coudda Shoudda Wouldda... of course I would learn that a week after our new infrastructure was built :) Apr 23, 2013 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.