Help Stop SOPA/PIPA

WordPress webdesign and development in Houston Texas

WordPress development with Git

An introduction to developing WordPress themes and plugins using Git version control

Adding Git to your WordPress development workflow - an introduction

Step 3: Setting up your repo for WordPress theme and plugin development

The power of Git besides being able to track your development changes is being able to quickly deploy a complete site to your production server including the latest version of WordPress. The WordPress team uses Subversion to track WordPress core changes but luckily there is a Git WordPress clone that updates every 30 minutes.

There are couple different routes you can take when setting up your repo with WordPress. Some developers prefer to keep the wp-content directory under version control separate from the core files then sym link to the version controlled wp-content dir that contains your theme and or plugin files that you will be working on.

Keeping things separate is probably best if you want to use one master repo for all the themes and plugins you work on but for this article we are going to clone the 3.2 branch from the WordPress Git repo and merge it with our remote repo. This will make it easier to deploy until we master more advanced deploy techniques like using Capistrano to automate the deploy process.

The git pull command allows us to clone the WordPress repo and merge it with our remote repo with one command. We can also specify the branch (currently WordPress is on 3.2-branch) we want to work with.

cd ~/sites/wp.dev
git pull https://github.com/markjaquith/WordPress.git 3.2-branch
git add .
git commit -m "added WordPress core files"

You will notice that when you try to make this commit you will get a message that your branch is ahead of origin/master

# On branch master
# Your branch is ahead of 'origin/master' by 16688 commits.
#
nothing to commit (working directory clean)

There might be a better way to add WordPress and keep it under version control but using this method we inherit all the core svn commits that were made to the 3.2-branch (Don’t worry any new additions will not cause problems)

Now that we have the WordPress core files in our repo lets go ahead and push them to our remote master

git push origin master

Before we start working we need to make a few changes to wp-config.php to use the local version of our database by creating a local-config.php file. (See Mark Jaquith’s postWordPress local dev tips: DB & plugins for detailed instructions on how to use a local-config.php file and disable plugins you don’t want to run on your local environment.

We want to keep wp-config.php under version control but tell WordPress to use our local DB_NAME, DB_USER, and DB_PASSWORD settings when we’re doing local development.

You can now create your theme or plugin files and start working and commit (check them in) as needed:

git add .
git commit -m "Your commit message"
git push origin master

Next Page - Step 4: Deploying to a live server

Pages: 1 2 3

1 Responses »

    Trackbacks

    1. Adding Git to your WordPress development workflow | C3M Digital on WordPress.com

    Leave a Response