Manage WordPress Plugins with GIT svn

posted in: Software, WordPress 0

This post is a work-in-progress. Please use at your own risk. If you have suggestions, email them to the webmaster at this site.

Using git as a source code manager, whenever I need to update a plugin, it is a challenge as I never remember the svn commands. And when I upgraded my computer, I opted not to install svn with the idea of just using git and git svn command.

Update the Readme on the Stable Tag

Before starting get the earliest revision number for your plugin.  This can be found on the plugin page, under the Development tab.  There is a link to the Development Log which will show all the revisions.  Note the initial revision number.

<plugin name> => replace with the plugin name, do not wrap the plugin name in <>

-r xxxxx => this is the revision number, replace xxxx with the number from above.

Create the local git repo from the wordpress svn repo.  The following command will create a new directory with the name of the plugin:

git svn clone --stdlayout -r xxxx<plugin name>

Change directories to the local git repo

cd <plugin name>

Confirm the git config has the svn-remote paths to trunk, branches, tags:

git config -l

git branch -r (shows origin/trunk)

Now the long part.  Fetch all the history from the svn repository.  The log-window-size options sets the read buffer.  The default is 100 and 1000 is faster for my configuration.

git svn fetch --log-window-size=1000

git branch -r  (shows trunk, branches, tags)

git checkout origin/tags/<stable tag>  (headless)

Make your changes

git commit -am"update tested up to value => 6.0"

git svn dcommit     (push to svn stable tag)

Now the trunk & master are out of sync with the tag.  Create a git temp-tag branch, merge it to the master and push the git master branch to the svn trunk.  Then delete the temp-tag branch

git switch -c <git temp branch name>

git checkout master

Sync the master with the updated stable tag

git merge temp-tag

Sync the trunk with the stable tag

git checkout origin/trunk

git svn dcommit

Now clean up the leftover temp tag branch in git.  If you need the current trunk or tag, just do another git checkout origin/trunk or /tags/xxxx

git branch -d temp-tag




Leave a Reply

Your email address will not be published.