If you are looking for a recommended way to deploy your WordPress plugins, skip to the UPDATE-section at the end of the article. If you’re interested in a git-svn workflow, read on. Thanks!
— — — — — — — — — — — — — — — — —
Git rocks and GitHub makes it even better. But if you develop a WordPress plugin and aim to share it with the world, you need to use svn. No way! git-svn to the rescue! (please play your favorite hero-appears-to-save-the-day soundfile) I assume you have your plugin on GitHub, requested a WordPress.org plugin repository and just received the confirmation mail. What now?
$ git svn init --trunk=trunk http://plugins.svn.wordpress.org/yourpluginnamehere $ git svn fetch
That might take a while. It’s svn.
$ git branch -a # Lists remotes/trunk $ git rebase --onto remotes/trunk --root master
Woozaa, git rebase magic! Well, it basically applies your linear history (master branch) to the svn repo (
remotes/trunk). Now all that’s left is sending the history to the svn repo.
$ git svn dcommit
Oh my god, I hope you don’t have hundreds of commits yet because that will commit each one separately! You probably like to keep your history in svn, so git-svn needs to send each and every commit separately. For me, it took about 30 seconds per commit. So you can estimate how long it might take for you. Gosh. Well, go grab a cup of your favorite hot (or cold, depends on the weather) beverage and enjoy the process. Oh, and WordPress.org will happily send you an email for every commit. Jeez. Congratulations, you’re done with the unpleasant part - enjoy your WordPress plugin development with git.
Develop as you’re used to with git. When you’re ready to release a new plugin version with svn, these are the required steps.
$ git svn dcommit $ git svn tag 1.3 # substitute with your version number
You might get errors like
W: Refspec glob conflict (ref:
refs/remotes/trunk):. Open your
.git/config and look for the
[svn-remote "svn"] block. Mine looks like this.
[svn-remote "svn"] url = http://plugins.svn.wordpress.org fetch = archivist-custom-archive-templates/trunk:refs/remotes/trunk branches = archivist-custom-archive-templates/branches/*:refs/remotes/* tags = archivist-custom-archive-templates/tags/*:refs/remotes/tags/*
For some reason, I had multiple lines starting with branches and tags. That confused git. Make sure there’s only one line for each option. Happy developing!
Do not do this. It looks like this workflow is unwelcome as it creates more commits than necessary. Anyway, I’m already doing it differently now. Develop in git to your liking. When you’re ready to release, bump your version number and simply deploy the current plugin state via svn:
$ svn commit -m "v1.2" $ svn copy http://plugins.svn.wordpress.org/myplugin/trunk http://plugins.svn.wordpress.org/myplugin/tags/1.2
To keep both repos clean, add the line
.svn to your
.gitignore. Then, type
svn propedit svn:ignore . in the plugin root. Add
.gitignore on separate lines.