WordPress Git Workflow Help

General Questions answered

Nr.1. Would like to have my git environment on my own server internally, not using Github to handle repos.

The first thing I’d do is to check out composer and how it works with WordPress, which is a project by Andrey “@Rarst” Savchenko.

Nr.2. Automatic creation of subdomains upon git branch creation (development.example.com, ryan.development.example.com) – Probably some shell script hook would be ideal for this.

This is something out of scope for this site. Either ask for help on StackOverflow or ask at your hoster. Some hosters don’t allow to edit these entries yourself.

Nr.3. Phing PHP/Shell script Handling of the db migration (something like this http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ ) to handle serialized database replacement upon pushing

I’d set up a multisite/network install. This allows to easily manage all the tables, keep the users in a central place, etc.

WP Gear – a project by Robert “@Wyck” Ellison – has a list of alternate build scripts. Including WordPhing written by himself. @TomJNowells/Interconnect.it script so far isn’t in that list.

Operation Questions answered

Nr. 1. getting the current latest wordpress version and branch it out, name of the branch gets a subdomain entry (branchdevelopment.domain.com)

Not sure why one wants to do this: A subdomain for each branch. When you look at the synced WordPress GitHub repository and the list of branches, then you’ll see that every branch is named X.Y-branch. So your subdomains would get named for e.g. 3.6-branch. I’m not sure if a subdomain is allowed to start with a digit (it should be, but ask your hoster) and then there’s the problem that you’d get a sub-subdomain named 6-branch, which has a sub-sub-subdomain named 3 and another one named 2. And guess pairing 2- and 3-version branches in a subdomain isn’t what you want to achieve.

In short: Just checkout 3.6-branch if you need to switch branches.

Nr.2. submodule the theme you desire if it’s available (i’d like to make my own git repo for this, as I use thesis I’d like to have a blank thesis git repo setup to grab from internally on the server that’s already been created)

Thomas “@toscho” Scholz has written a nice plugin that allows us to use a subdomain to handle themes outside the WordPress directory. You can find it in this answer as well as in this one. Even automatic updates will work for themes since WP 3.6.

You can do the same for MU-Plugins and Plugins by simply setting the following constants in your wp-config.php file:

define( 'WP_PLUGIN_DIR',   'path/to/your/plugins.dev/folder/plugins' );
define( 'WP_PLUGIN_URL',   'https://plugins.dev/plugins' );
define( 'WPMU_PLUGIN_DIR', 'path/to/your/plugins.dev/folder/mu-plugins' );
define( 'WPMU_PLUGIN_URL', 'https://plugins.dev/mu-plugins' );

Now simply put all your plugins and themes under version control and push them onto your server. You can easily make them all available using either mu-plugins or default plugins that get network activated.

Nr.3 checkout and make changes, client reviews, once it’s pushed to live, the database script will then kick in automatically changing the serialized url values from localhost (or subdomain) to the live url

If Toms script/plugin doesn’t help you so far, then be told that he accepts pull request on GitHub.

Leave a Comment