Git Workflow with WordPress

If there was a way to streamline your code backup, development, and deployment would you do it? Git is a solid solution, but benefits from some fine tuning to improve WordPress development.

Starting from Scratch

If you’re unfamiliar with Git download the Github desktop app to get started. Github has a quick start guide to get up and running, which is all you’ll need for this post. If you’d like to go more in depth there’s a free course at CodeCademy which takes a couple hours to complete.

Why use Git for WordPress development?

  • Automatic backup of your code
  • Easy method to undo changes
  • View changes across your commits (useful when clients want something how it was 3 months ago)
  • Work on bug fixes, and new features, and with others without interfering with your existing (working) code with branches

Ignoring Non-essential Files

If you commit the entire WordPress install to your repository you end up with a lot of fluff that could trip you up later. If you need to roll back a change, but that specific commit was bundled with a WordPress update where some core files got changed, rolling back would affect your WordPress installation. This also affects the install of anyone else working on the same code.

Ideally you would only commit the files you’re actively working on such as custom themes and plugins. You can tell Git to only look at your custom themes and plugins with a .gitignore file placed at the root of your project folder. A good starting point might look something like:

Connecting Git to Your Server

Using a service such as Beanstalk or Springloops you can have your changes automatically uploaded to your server. Your site run into an issue after an update? No problem, roll it back to a commit you knew worked immediately.