One of my favorite features of WPEngine is their integrated
git push for deployment. Instead of manually SFTP’ing files back and forth, you can easily push code changes while keeping your code version controlled.
WPEngine lets you create unlimited transferrable installs, so you can easily use it for all your site development. When it’s time to go live, you simply type in your client’s email address and they’ll get a direct email walking them through the transfer process.
Create a site on WPEngine
From your WPEngine dashboard, click “Add Install” and give it a name. Once created, you can clone an existing live site here by installing the WPEngine Automated Migration plugin on the live site, typing in your WPE install details, and letting it handle the migration of everything.
Once the install has been created, click “Git Push” in the sidebar, type in your name, and paste your SSH public key. This support article by WPEngine will walk you through it.
Open Terminal and initialize git in the top level of the website:
git init. While you could use it to version control everything (WP core, themes, plugins…), it makes sense to limit it to just the code you’re actively editing using a .gitignore file. I limit it to my custom theme and core functionality plugin. Here’s my gitignore file.
If you’ve created a repo on GitHub, click “Clone or Download” (screenshot), copy the URL they give you, and set it up as a remote. For instance, for my EA Starter theme I would use:
git remote add origin firstname.lastname@example.org:billerickson/EA-Starter.git
Go back to the Git Push page in the WPEngine dashboard. In the bottom of the right column you’ll see the two remotes corresponding to your production and staging environment. Add them (make sure you use the correct URL). Example:
git remote add production email@example.com:production/mysite.git git remote add staging firstname.lastname@example.org/mysite.git
Pushing code updates
As you develop your site, periodically commit your changes:
git commit -am 'this is my great commit message'. Push those changes to GitHub:
git push origin master. And when you’re ready to push to your production or staging site, simply push to the remote:
git push production master.
WPEngine will scan the files, make sure there’s no PHP errors, update the correct files, and clear your cache.
I also recommend using WP Migrate DB Pro to push/pull your database and media. If your site has lots of media, skip the media syncing and use BE Media from Production so that your local install will reference the production site for media rather than having to store a copy of everything locally.