Call + (44) 0843 289 4539

  • No products in the cart.

WordPress Plugins : Git, GitHub and Subversion Workflow

Our release of our Stop Web Crawlers WordPress Plug-in,  is now available on the plug-in directory,  the initial release of the code to the directory presented us with an interesting challenge of integrating tow different Source Code Version Control Repositories.

Our internally we primarily  use Git and public GitHub repositories for  Stop Web Crawlers plugin version control. However make use of Subversion to manage the release versions of plugins.

The WordPress Plug-ins Directory is a hosting site, not a listing site. We didn’t really want to switch to Subversion internally just to support all the future WordPress Plug-ins.

We wanted to make use of our Git and GitHub repositories but still only publish new versions of our plug-ins once they are ready for release to the WordPress Plug-in Directory.  Fortunately, after thankfully finding Ben Lobaugh’s blog post this easy enough to implement.  The following can be used as a guide to provide you with the basics for you to develop further.

Linux and Mac

We make use of Linux or Mac OSX to do all of our development, so the instructions below are most suited to these environments.

[well type=””]
If you’re running Mac OSX you may want to install the HomeBrew package manager

Install HomeBrew on Mac

Install Git and Subversion

To ensure you have both Git and Subversion installed your system, you can simply install them using the following terminal commands.


[pastacode manual=”%23%23%20Install%20Git%0D%0Asudo%20apt-get%20install%20git%0D%0A%0D%0A%23%23install%20subversion%0D%0Asudo%20apt-get%20install%20subversion%0D%0A” provider=”manual” lang=”sh”/]


[pastacode manual=”%23%23%20Install%20Subversion%20via%20HomeBrew%20on%20Mac%0D%0Abrew%20install%20svn%20%20%0D%0Aor%20%0D%0Abrew%20install%20subversion%20%0D%0A” provider=”manual” lang=”sh”/]

Create .gitignore and .svnignore files

You may not want to exclude some files from each of the repositories. i.e.  Your eclipse build folders and file from your Subversion repositories.  Our bet practice is create gitignore files and subversion ignore files to exclude any files we don’t want to share.

[pastacode manual=”*.log%0D%0Awp-config.php%0D%0Awp-content%2Fadvanced-cache.php%0D%0Awp-content%2Fbackup-db%2F%0D%0Awp-content%2Fbackups%2F%0D%0Awp-content%2Fblogs.dir%2F%0D%0Awp-content%2Fcache%2F%0D%0Awp-content%2Fupgrade%2F%0D%0Awp-content%2Fuploads%2F%0D%0Awp-content%2Fwp-cache-config.php%0D%0Awp-content%2Fplugins%2Fhello.php%0D%0A%0D%0A%2F.htaccess%0D%0A%2Flicense.txt%0D%0A%2Freadme.html%0D%0A%2Fsitemap.xml%0D%0A%2Fsitemap.xml.gz%0D%0A*.buildpath%0D%0A*.project%0D%0A*.settings%0D%0A%0D%0A%0D%0A” provider=”manual” lang=”sh”/]

[pastacode manual=”*.log%0D%0Awp-config.php%0D%0Awp-content%2Fadvanced-cache.php%0D%0Awp-content%2Fbackup-db%2F%0D%0Awp-content%2Fbackups%2F%0D%0Awp-content%2Fblogs.dir%2F%0D%0Awp-content%2Fcache%2F%0D%0Awp-content%2Fupgrade%2F%0D%0Awp-content%2Fuploads%2F%0D%0Awp-content%2Fwp-cache-config.php%0D%0Awp-content%2Fplugins%2Fhello.php%0D%0A%0D%0A%2F.htaccess%0D%0A%2Flicense.txt%0D%0A%2Freadme.html%0D%0A%2Fsitemap.xml%0D%0A%2Fsitemap.xml.gz%0D%0A*.buildpath%0D%0A*.settings%0D%0A*.project%0D%0A” provider=”manual” lang=”javascript”/]

The process may change a little depending on where in the Software Development Lifecyle you’re in. So for instance if you’re just starting out you may want to create your GitHub repository, or if you’re wokring off a mature GitHub repository you may just want to clone it

Create GitHub Repository

You may want initially create your GitHub repository using the initialize the Git repository on your local machine and configure the remote for you GitHub and commit and push your files.

[pastacode manual=”%23%23%20Initialise%20git%20in%20your%20directory%0D%0Agit%20init%0D%0A%23%23%20add%20all%20files%20in%20your%20current%20directory%0D%0Agit%20add%20.%0D%0A%23%23%20Commit%20all%20files%20and%20folders%20%0D%0Agit%20commit%20-am%20%22Some%20meaningful%20comment%22%20%0D%0A%23%23%20Configure%20you%20remote%20GitHub%20Repository%0D%0A%23%23%20REMEMBER%20TO%20USE%20YOUR%20REPOSITORY%20URL!!!!!%0D%0A%23%23%20Push%20all%20your%20current%20files%20%0D%0Agit%20push%20-u%20origin%20master%0D%0A%0D%0A” provider=”manual” lang=”sh”/]

Clone exisitng Git Hub Repo

Clone using SSH

[pastacode manual=”” provider=”manual” lang=”sh”/]

Clone using HTTPS

[pastacode manual=”” provider=”manual” lang=”sh”/]

When your repository cloning is complete. You will need to change directory into your working directory

[pastacode manual=”cd%20StopWebCrawlers%0D%0A” provider=”manual” lang=”sh”/]

Set up a Subversion tracking branch

We will create a branch that will only be used for keeping track of the changes between the two repositories.  You will never carry out any software development directly on this branch. We will only be making use of Git’s merging capabilities to merge and publish our changes on this branch to our subversion repository.

[pastacode manual=”git%20branch%20––prefix%3Dorigin%2F%0D%0Agit%20svn%20fetch%20%20–log-window-size%2010000%20%20%20%20%23CAUTION%20THIS%20LINE%20TAKES%20A%20LONG%20TIME%20TO%20COMPLETE%0D%0Agit%20reset%20–hard%20origin%2Ftrunk” provider=”manual” lang=”sh”/]

Daily Development operations

Once this is all set up, we can now continue with a daily operations, adding new features and fixing bugs etc. Once we’re ready to update the release on subversion we simply, need to merge our subversion branch and development branch.

Merge changes from subversion to Github

[pastacode manual=”git%20checkout%20svnsync%0D%0Agit%20svn%20rebase%0D%0Agit%20checkout%20master%0D%0Agit%20merge%20svnsync%0D%0Agit%20push%20origin%20master” provider=”manual” lang=”sh”/]


Merges changes from Github and publish to subversion

[pastacode manual=”git%20checkout%20master%0D%0Agit%20pull%20origin%20master%0D%0Agit%20checkout%20svnsync%0D%0Agit%20svn%20rebase%0D%0Agit%20merge%20–no-ff%20master%0D%0Agit%20commit%0D%0Agit%20svn%20dcommit” provider=”manual” lang=”sh”/]


Follow Me