I’ve shared this script at a few conferences, used it on several servers, and it is still unmatched by most web host’s git deployment methods.
The unique feature of this script is that it performs a two-way sync via git. Most services only handle deployment, pushing local changes to the server. Using an intermediary such as GitLab or Github, this script pushes changes from your desktop to the server, and changes on the server go to your desktop. That’s important when you’re using something like WordPress or Drupal and want to use the one-click updates.
- This script is super lightweight. If you’re already running a PHP app, why would you want to install Ruby or something else just for deployments?
- This script, unlike many others, is two-way. That means if you’re running WordPress you can still do you automatic updates right on the server, all while still having the warm sweet safety of a version to roll back to.
- Setup can be a bit of a pain. You’ll need to set up a git user for your web server, along with proper permissions. If you’re not familiar with command-line git or linux permissions… well then you’re probably not looking for this script to begin with.
- The only other con is that this script will blindly commit any changes on the server. That includes hacked code. This isn’t always a bad thing though. If you’re keeping an eye on your code, and you should, then you’ll notice when/if the server user makes unexpected commits. If you want, you can even set up alerts. You’ll have to roll back in the case of a hack, but you’ll also be able to very clearly see what code was manipulated. This can go a long way in sealing the hole after your recovery.
Here’s a screenshot of what the end result looks like. Here you can see my usual theme alterations and a few plugin additions, and you can also see the automatic commits from the server. I use a picture of my adorable dog so the cuteness sticks out.