Using git for WordPress development
git is a powerful revision control system. It is a distributed system. This means that you can commit, create branches or tags on your local hard drive without any network connection. Read more about git on the project’s website, there’s also great documentation there.
If you write WordPress plugins and want them to be published on the WordPress plugins page you have to use svn which can be painful once you’re used to git.
Fortunately, git can interact with svn via git-svn. Here’s a list of the commands you will need to use.
git svn init -s http://svn.wp-plugins.org/your_plugin
This will initialize a local git repository. Inside the repository, use
git svn fetch git gc git branch -a
The first command will take a few minutes and fetch all tags, branches etc. from the svn repository. The second command cleans up your git repository. This will significantly reduce it’s size. The last command will list all branches, local and remote. To track the remote trunk in a local branch use
git checkout -b svn-trunk trunk
svn-trunk is just the name the local branch gets in this example, you can use anything you like.
A normal workflow usually looks like this:
git checkout -b newbranch # create a local branch that you edit ... edit ... git commit -m "Added awesome new feature" -a git checkout svn-trunk git merge newbranch git svn dcommit
These commands create a local branch where you can try new things. Commit the changes to your local branch. Then check out the local svn-trunk branch that tracks the remote WordPress repository, merge the changes from newbranch. The last command will update the remote svn trunk, assuming you really named your local trunk branch svn-trunk. As we’re talking about WordPress plugins you’ll want to tag your commit so that older versions of your plugin can still be downloaded.
git svn tag version
This will create the tag in the remote svn repository. It looks like this is only possible since git 1.6.1. For Debian Lenny systems you’ll need git from backports.org for this to work.
This should get you started with git and WordPress plugin development. Please do read the git documentation for more details, as git-svn has some limitations: Only use the described workflow if you’re the only commiter and work with one git repository.














I added your blog to bookmarks. And i’ll read your articles more often!
Thanks Brown! What a nice comment. Too bad I had to remove all the viagra links