How to use Git with WPEngine

3 minute read

For reference/introduction please be familiar with the following links

Pre-Requisites

You’ll need a way to work with Git and Github. Your choices are

I am assuming you know how to setup a local development environment for your needs, there are too many ways that work, and I can’t cover every scenario.

WP-Engine Nomenclature

There are a few things that are idiosyncratic to WP Engine/WordPress hosts/WordPress Build process that can be confusing to someone who’s coming from a more standard one client, one project environment. So, for the sake of clarity, I am giving you my definition of what things are.

Site A site here is overarching project you’re working for. Say you’re working on a client named Acme. We’re going to call it the Acme site

Install/Environment At WP Engine, each site can have 3 installs, which they call environments, so you can have a production install, staging install and a development install. Each install has a unique name within all of WP Engine, so you can have something like

  • acmesitedev.wpengine.com aka the “Acme Dev Site” or “Acme Dev Install”
  • acmesitestage.wpengine.com aka “Acme Staging Site” or “Acme Staging Install”
  • acmesiteprod.wpengine.com aka “Acme Production Site”, or “Acme Live Site”

With that in mind, this specific repository is for the Skunkworks site. This repository will be used to push changes to all 3 installs/environments of the site.

Setup a local development environment

  1. Clone the repository to your workstation.
  2. Copy the wp-sample-config.php to wp-config and edit it so that you have a local development environment.
  3. Make sure you can login, and access your local environment and do work.
1
2
3
4
    git clone https://github.com/pearanalytics/skunkworks.git
    cd skunkworks
    cp wp-config-sample.php wp-config.php 

Add WP Engine as a remote

This can be tricky and confusing at first, so go through this section slowly. You need to add the Git repository at WP Engine for this install as a remote, since WP engi

Development Environment

1
    git remote add wpe-dev git@git.wpengine.com:production/skunkwrksdev

Staging Environment

1
    git remote add wpe-stage git@git.wpengine.com:production/skunkwrkstg

Production Environment

1
    git remote add wpe-prod git@git.wpengine.com:production/skunkwrksprod

Push Changes to Github

Once you’re done making changes, whether it be modifying files, or adding new files and folders, you will need to eventually push the changes to Github.

1
    git push origin main

Deploying to WP Engine

Deploy to the Dev Install

1
    git push wpe-dev main

Caveats/Issues

Running the command above ensures that all of our local files that matter have been pushed to Github, and to the development install at WP Engine. Depending on the types of changes we made to the file system, we may still need to log in and make some changes.

  1. We still need to login and activate any new plugins we may have added.
  2. If a plugin update requires an update to the database, we need to login and run the update.
  3. Any settings changes need to be applied manually.

The take away is, once you’ve done the push, don’t just walk away, check the install url, and apply any changes that need to be made.