SVN is so WordPress 2.0: Updating your git-controlled WordPress
A couple of months ago, I wrote an article entitled SVN is so WordPress 2.0: Using git to manage a WordPress 3.0 installation. This article explained how to migrate an existing WordPress installation to a git-managed installation, much like using Subversion to manage it.
That post detailed how to migrate and the instructions could very easily be adapted to create a new installation. This post details how to upgrade to the latest release of WordPress whenever it is released.
Unfortunately, I’ve found that the WordPress team, perhaps git-svn, doesn’t import svn tags, so we need to do some sleuthing to find out exactly which tag to use.
The first stop is finding out the last svn revision used for the tag. Use this command to do so. Replace the version number with the one applicable to the upgrade you wish to perform.
svn log -v -q --stop-on-copy http://svn.automattic.com/wordpress/tags/3.0.1/ | less
The output of that for me is this:
------------------------------------------------------------------------ r15479 | nacin | 2010-07-29 17:57:26 -0400 (Thu, 29 Jul 2010) Changed paths: M /tags/3.0.1/wp-includes/capabilities.php M /tags/3.0.1/wp-includes/version.php ------------------------------------------------------------------------ r15477 | ryan | 2010-07-29 17:09:29 -0400 (Thu, 29 Jul 2010) Changed paths: A /tags/3.0.1 (from /branches/3.0:15476) ------------------------------------------------------------------------
Looking at the revisions, I’m looking for a revision 15479 or shortly there after.
Next, I use the WordPress Codex entry for the release to find what date it was released. Version 3.0.1 was released July 29, 2010, so that gives me a pretty good approximate date for the last commit. The svn log above also shows this date, but I figured there might be some lag between the final commit and when the release came out. You could probably skip this step. Don’t judge me.
I then go to WordPress’s Github’s commit history on its master branch and look for a commit on the date above. There are two: 20812cf38b99a40a0e3c1d3dd5c2b3d20fb893b5 and 2f27661e1afffe16ecfbaf7a5b02db8f47e46482. Looking at the log for each, I see this line:
git-svn-id: http://core.svn.wordpress.org/trunk@15480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Revision 15480 is approximately right at the above, and looking at the changeset shows that this is probably what I want.
I do wish there was a commit which was right on, though.
So, now that I know the commit id, I can use it with git.
The rest is easy! Well, sorta. For the love of $deity, back up your blog, both the files and the database, before you do anything past here.
Once I’m in my git-versioned WordPress directory, I had a little bit of cleanup to do. I’d inadvertently added some files in wp-content/cache, so I had to manually remove them with git rm and also update my sitemap.xml and sitemap.xml.gz with git add sitemap.xml* and git commit.
Then, I could proceed.
git fetch gh
git merge 2f27661e1afffe16ecfbaf7a5b02db8f47e46482
Remember that you really only need to use enough of the commit id hash to uniquely identify the commit. If I recall correctly, seven characters is usually enough, and git will warn you if your choice is ambiguous. I used the full one because I copied and pasted.
Here’s my transcript from these commands so you know what it should look like:
[colin@convoy blog]$ git fetch gh remote: Counting objects: 860, done. remote: Compressing objects: 100% (591/591), done. remote: Total 749 (delta 568), reused 202 (delta 155) Receiving objects: 100% (749/749), 312.70 KiB, done. Resolving deltas: 100% (568/568), completed with 104 local objects. From git://github.com/wordpress/wordpress c39484b..6e44120 master -> gh/master [colin@convoy blog]$ git status # On branch master nothing to commit (working directory clean) [colin@convoy blog]$ git merge 2f27661e1afffe16ecfbaf7a5b02db8f47e46482 Auto-merged readme.html Merge made by recursive. readme.html | 2 +- wp-activate.php | 2 +- wp-admin/admin-ajax.php | 22 +- wp-admin/admin.php | 12 +- wp-admin/edit-attachment-rows.php | 4 +- wp-admin/edit-tags.php | 7 + wp-admin/edit.php | 11 +- wp-admin/export.php | 12 +- wp-admin/import.php | 2 +- wp-admin/includes/bookmark.php | 4 +- wp-admin/includes/class-wp-importer.php | 5 +- wp-admin/includes/class-wp-upgrader.php | 33 ++- wp-admin/includes/dashboard.php | 4 +- wp-admin/includes/deprecated.php | 10 +- wp-admin/includes/export.php | 2 +- wp-admin/includes/media.php | 2 +- wp-admin/includes/meta-boxes.php | 4 +- wp-admin/includes/ms.php | 48 ++-- wp-admin/includes/nav-menu.php | 2 +- wp-admin/includes/plugin-install.php | 13 +- wp-admin/includes/plugin.php | 3 +- wp-admin/includes/post.php | 20 +- wp-admin/includes/schema.php | 9 +- wp-admin/includes/template.php | 288 ++++++++--------- wp-admin/includes/theme.php | 6 +- wp-admin/includes/update.php | 6 +- wp-admin/includes/upgrade.php | 12 +- wp-admin/includes/user.php | 8 +- wp-admin/install-helper.php | 10 +- wp-admin/install.php | 2 +- wp-admin/menu.php | 4 +- wp-admin/ms-edit.php | 13 +- wp-admin/ms-sites.php | 5 +- wp-admin/nav-menus.php | 15 +- wp-admin/options-discussion.php | 2 +- wp-admin/options-permalink.php | 51 +--- wp-admin/plugins.php | 23 +- wp-admin/press-this.php | 2 +- wp-admin/update-core.php | 4 +- wp-admin/user-new.php | 4 +- wp-app.php | 2 +- wp-content/themes/twentyten/attachment.php | 12 +- wp-content/themes/twentyten/editor-style.css | 8 +- wp-content/themes/twentyten/functions.php | 58 ---- wp-content/themes/twentyten/header.php | 16 +- .../themes/twentyten/languages/twentyten.pot | 123 ++++---- wp-content/themes/twentyten/loop.php | 33 +- wp-content/themes/twentyten/page.php | 8 +- wp-content/themes/twentyten/style.css | 340 +++++++++----------- wp-includes/canonical.php | 14 +- wp-includes/capabilities.php | 12 +- wp-includes/category-template.php | 4 +- wp-includes/class-http.php | 54 ++-- wp-includes/classes.php | 2 +- wp-includes/comment-template.php | 46 +++- wp-includes/cron.php | 8 +- wp-includes/default-filters.php | 2 +- wp-includes/default-widgets.php | 2 + wp-includes/deprecated.php | 19 +- wp-includes/feed.php | 2 +- wp-includes/formatting.php | 14 +- wp-includes/functions.php | 15 +- wp-includes/general-template.php | 11 +- wp-includes/kses.php | 4 +- wp-includes/link-template.php | 6 +- wp-includes/media.php | 2 +- wp-includes/meta.php | 2 +- wp-includes/ms-blogs.php | 20 +- wp-includes/ms-deprecated.php | 14 +- wp-includes/ms-functions.php | 27 +- wp-includes/ms-load.php | 7 +- wp-includes/nav-menu-template.php | 35 ++- wp-includes/nav-menu.php | 17 + wp-includes/post-thumbnail-template.php | 2 +- wp-includes/post.php | 26 +- wp-includes/query.php | 3 +- wp-includes/taxonomy.php | 34 +- wp-includes/theme.php | 4 +- wp-includes/update.php | 47 ++-- wp-includes/user.php | 4 +- wp-includes/version.php | 4 +- wp-includes/wp-db.php | 9 +- wp-signup.php | 5 +- xmlrpc.php | 10 +- 84 files changed, 903 insertions(+), 872 deletions(-) [colin@convoy blog]$ git status # On branch master nothing to commit (working directory clean)
The last thing to do is go to /wp-admin/upgrade.php in your browser. You’ll likely be redirected there when you hit the admin panel anyway, so it’s likely easier simply to do that.
Is managing the installation with git easier than managing it with svn? So far, not really. Subversion’s svn switch and WordPress’s use of SVN tags makes using git with it a little frustrating. If WordPress were ever to switch to git for real, then they’d likely use tags and all this searching would be moot. One could just switch branches and be done with it.
Got an easier way? Tell me in the comments.

