WordPress and Git Workflow

I know this question has been asked a thousand times, but I’m really trying to work out how to get the best out of Git when working with WordPress.

I’ve scoured the web and read dozens of articles, all that seem to cover the topic briefly. Here’s a few of the most notable one’s I’ve read recently.

– Version Controlling WordPress

– Managing WordPress Theme Deployments with Git

– Manage your custom WordPress theme using git instead of FTP

Currently, my workflow looks like this.

  • Install WordPress locally
  • Develop Theme
  • Export WordPress Databases from local server
  • Import WordPress Database to remote server
  • Upload WordPress files and theme via FTP
  • Client makes changes
  • Download WordPress files and theme via FTP and export WordPress Databases from remote server
  • Replace files locally
  • Make development changes
  • Re-upload via FTP, export and import database to remote server

I realise Git can streamline this process. It seems the best way to do this is to have a .gitignore file that ignores certain directories that don’t need to be tracked, as well as having both a local and remote wp-config.php file.

But how do you handle the databases? Clients will usually make changes (posts/pages/plugins). Do I still need to export from the remote database and import back on my local server?

Can someone suggest the best workflow for me here? And walk me through the steps.

Also, I’d probably like to use Bitbucket as private repos with them are free, unlike GitHub.

Any help would be appreciated.

Thanks in advance!


I’m one of the developers of WP Migrate DB Pro, and would like to answer @Ennui’s question:

“Do you know if the db url replace script it runs takes into account serialized strings?”

Yes, it does handle serialized data. In fact, that is the primary reason I developed the free version of the plugin back in 2009. 🙂

Unfortunately I only have a reputation of 41, so couldn’t reply to @Ennui’s comment. Sorry for that.

Leave a Comment