Many people have taken time and effort to learn how to use WordPress and it has become sort of a standard website publishing platform in last couple of years. The WordPress team has also made it very easy to use the platform – even for a beginner, with a little bit of training, he/she can update content fairly easily.
However, any customizations to a theme or templates or creating custom plugins still require pushing code or updates to a production server. For simple sites, this is not an issue at all. But for companies managing more complex WordPress or Drupal sites with frequent updates to the code and pushing them to production, they need to have a good process in place to manage deployment.
In the past, FTP was the primary tool to push changes to production. You’d connect to the server using an FTP client like FileZilla and manually uploaded files. I still see many organizations using manual FTP upload. However, using FTP to manage deployment has several issues.
One, since you are uploading files to a server manually, you have to remember which files have changed, manually drill down into each folder, and upload each file. This is very time-consuming and prone to human errors where you can forget which files were uploaded vs which files need to be uploaded.
Two, if you manage multiple environments such as staging and production, which is what I recommend for managing a complex website, then you have to remember which files were uploaded on staging vs on production. What about if you have a 3rd environment for development? On Pantheon hosting company, they give you three environments: dev, test, and production.
Either way, using FTP to manage deployment is very 90s and early 2000s. More modern approach is to use git deployment and this will make your life much easier.
The way it works is all the source code – at least the ones that many change frequently – under git repository. Git is a source control management tool that can house code for your website. And you can set it up so that you deploy changes using git.
If you are new to the concept of git, think of it as code tracking system. Let’s say that you want to change the size of heading on your landing page and make it bigger – 30px instead of 24px. You’d do this in a CSS file. If your website code is stored in git repository, these changes are all logged. Giving a full overview of what git does is beyond the scope of this blog post – just keep in mind that, at a high-level, it’s used to track all changes to your code.
Also, because all changes are logged in a git repository, you know for sure that when you push your git repository to production, that it will always be the latest updates that will be pushed to production.
Now, git deploy is a concept that, instead of using FTP to manually upload files to a server one by one, you tell git to push the latest changes to production. The benefits of using git deploy are:
- Git automatically detects the changes made since your last deployment and deploys only the changes. You don’t have to remember or keep track of which files were changed. Git takes care of this for you.
- It takes a simple command such as “git production deploy master” to deploy all your changes. Once you run the command, git takes care of everything.
- Since changes to your website are logged in commits (group of changes you send to a git server), after pushing changes to production, you can easily roll back to a previous version of a website should you need to for any reason.
- Since git uses a centralized repository, you can use git deploy to deploy to different environments including dev, test, and production. This makes keeping all environments synced much easier.
For any mission-critical websites we manage, we use git and git deploy. The only time we use FTP to manually upload changes files are when our clients are on a server that does not provide git deploy. If that’s the case for you, I’d recommend finding a more modern web hosting platforms like WP Engine and Pantheon. The latest version of Plesk platform also supports git deployment. So reach out to your web hosting provider and see if they support git deployment.
Git deployment is truly a modern way to manage website deployment and I encourage everyone to look into it if you have a website that requires customizations and constant updates to code. If you found this article helpful, you may also want to check out Setting up WordPress for Local Development with Git that we published last year.