GitHub Projects as Subversion Externals

GitHub Projects as Subversion Externals

It’s probably a no-brainer, but this totally blew my brains out. Apparently you can use Subversion with GitHub repositories! So if you’re a fan of Subversion externals, and like to include themes and plugins using svn:externals like this:

akismet http://plugins.svn.wordpress.org/akismet/tags/2.5.6/
jetpack http://plugins.svn.wordpress.org/jetpack/tags/1.7/

You’re gonna love the fact, that if the theme or plugin is not hosted in a Subversion repository, but on GitHub only (such as the _s theme), you can still include it with svn:externals like so:

_s https://github.com/Automattic/_s/trunk

And every time you svn update, Subversion will pull the latest version of the Underscores theme directly from GitHub. Boom!

Unfortunately this doesn’t seem to work vice-versa. According to this thread, it’s not possible to set up a Subversion repository as a Git submodule. However, you can mirror things, just like the WordPress mirror on GitHub!

To learn more about external references is source control, visit Subversion Externals and Git Submodules.

What about you? What’s your current workflow with WordPress themes and plugins? Do you use external references, or do you keep a copy of themes and plugin files in your own code base, and update them when updates ship? Share your thoughts in the comments section and have a great weekend!

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

7 comments

  • Nice! I started using externals recently and being able to use Github repositories as subversion externals is great. Thanks for the tip Konstantin!

  • Sounds interesting, but haven’t worked in this way before. Could you explain how using external references can be useful to a WordPress user?

    • Jean, good question! When working on a project, all your code is (or is supposed to be) in source control. This includes things like themes, plugins and even core itself. Now, when updating themes, plugins and core, WordPress will overwrite the old files with the new files, so you’ll have to add those to source control and commit them, to avoid conflicts at a later stage.

      Now, you can tell Subversion (or Git) that instead of maintaining a copy of WordPress, themes and plugins in your repository, use external references. An external reference to the latest version of core, to the themes from the repos and to the plugins that you use. So when a new update comes, instead of performing the upgrade from your Dashboard, you just change the version number in these external references and run the svn up (or git pull) command, which will pull in the new files, replacing the old ones.

      It’s not as easy as the one-click upgrade from the Dashboard, but when you want to keep things in source control and easily roll back updates when they go wrong, external references is a good thing. Tools like Capistrano may also help.