Any sane way of setting up version control for wordpress development (including database changes)?

Hello all,

I’m currently part of a company’s web dev team working on a wordpress website.

The workflow is rather archaic – we have a live server, and a staging server which we manually create from time to time, by deleting the existing staging server and then duplicating the current live server.

All 3 of us work on the same staging server, which is fantastic. For instance, If two people work on something at the same time, they can overwrite each others’ changes.

We also make note of every change we make on staging, so when changes are ready to push live, we can then make the exact same changes on live. (Pushing was deemed too dangerous by the powers above).

Needless to say, the system is extremely inefficient, especially for someone coming from a software development background.

Now I have set up my own local test environment, so I can at least test some changes on a separate environment without interference from the rest of the team.

And I have also read about ways we can utilize a GIT repo, and push changes from our local dev environments to a staging (or live) server that way. But this only covers actual file changes. The majority of the work we do does not actually involve files. It involves changing plugin settings, adjusting things in wpbakery, adding ACF fields, or adding scripts into individual pages. And correct me if I am wrong, but I believe these are all stored in the database?

So what would be a sane way to set up a dev pipeline? I’d love to have a GIT like system that allows us to track and merge these changes to the wordpress database, with a proper version history. But I couldn’t find anything on this topic.

Any pointers would be appreciated!

4 Comments
  1. I think this has been discussed in /r/prowordpress a couple of times, you might have better luck there.

    As a 7 year WordPress developer, I have yet to find a proper way to utilize Git. I’m sure it can be done, but 90% of my clients are so small and on random hosts that I’d rather just FTP some small changes live, or use your workflow of locally testing and pushing changes.

  2. Never push db to live..

    Acf fields can be git tracked through acf-json directory..

    I do not use wp bakery but doing custom themes so 99% of changes to site will be done over with code so cannot help with this.

  3. I have played around with implementing some CI/CD pipelines for wordpress, specifically a managed wordpress instance, and I’ve found some things that work. At the core of it all has been [WP-CLI](https://wp-cli.org/) backed by ansible.

    I use siteground for hosting and they grant you SSH access to your instance. Creating an ansible playbook to run wp-cli commands is pretty straight forward.

    One thing I have not automated yet are updates that require a bit more logic than ansible is designed to handle. For example, adding new links to a menu and deleting ones that are no longer being used. But wp-cli does have an [eval](https://developer.wordpress.org/cli/commands/eval/) command. My plan was to create a `my-site-init.php` and use the wordpress API to make any more complex changes.

    In git I use a `develop` branch for my staging instance and then changes to `main` go to prod. The CI pipeline builds my custom theme (which is just a CSS preprocessor), downloads all plugins at their specified versions, then uses ansible to copy everything to the wordpress server, and then runs the CLI commands to activate everything and set any site [options](https://developer.wordpress.org/cli/commands/option/).

    Another thing I’ve fiddled with is creating content on a separate instance and then [importing](https://developer.wordpress.org/cli/commands/import/) it. But I think I’d only want to do this for “static” content like my about page, not actual posts.

    I am also a software engineer so the idea of just making changes on prod gave me anxiety.

    The follow up to all of this automation has been planning for horizontal scalability. At that point I think I’d have to break away from managed hosting and then I’d probably build a docker container with all the themes/plugins included. Easier than remotely managing multiple VMs.

  4. this is the best solution I’ve found for managing / migrating / syncing wp dbs-

    [https://deliciousbrains.com/wp-migrate-db-pro/](https://deliciousbrains.com/wp-migrate-db-pro/)

    for ACF, use local JSON, this allows you to manage acf configs in version control-

    [https://www.advancedcustomfields.com/resources/local-json/](https://www.advancedcustomfields.com/resources/local-json/)

    We used git successfully for version control of filesystem changes. A developer would work in a feature branch on their local instance, then deploy to staging for testing and approval. Once approved, the feature branch would be merged into the master branch then deployed to production.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer