As any regular reader of this blog will know…
*watches as tumble-weed bounces across the void*
The problem I quickly discovered was that all of my (and my employer’s) customers used shared hosting, which meant being limited to FTP for uploading changes to their websites.
This meant that when it came to deploying my changes to the server, I still had to find and upload each of the changed files manually (or think “sod it” and upload them all, to make sure I didn’t miss any).
And, if I’m honest, this became quite repetitive and boring… So what should you do if you want to automatically deploy from Git via FTP?
git-ftp to the rescue
git-ftp is a free and open source Bash script that allows you to push files in a Git repository via FTP to a remote server. But rather than upload all the files each time you push, git-ftp is intelligent enough to only upload (or delete) files that have changed since the last push.
It also has additional features such as configuration of an ignore file, which will prevent any specified files from uploading, and the ability to perform dry-runs, which simulates the upload facility, to make sure that nothing will go wrong before you do push for real.
Installing git-ftp was so simple that even I (a Neanderthal when it comes to most things Linux) was able to do it without issue, and once a repository is configured with the correct FTP settings:
$ git config git-ftp.user daniel $ git config git-ftp.url ftp.example.com $ git config git-ftp.password s3xyAnd1Kn0wIt
and an initial git-ftp initiation process is completed, pushing the most recent changes is a simple as:
$ git ftp push
To help avoid confusion, I figured it would be important to point out that there is another project hosted on github which has the same name, and does the same thing, as the aforementioned git-ftp, but is written in Python rather than Bash. As I’ve not used it, I cannot comment on it, but if Python is your thing, then you might be interested in trying that instead.
Alternatively, if you don’t mind spending a bit of money, it might be worth taking a look at Beanstalk. This is designed to be an all-in-one solution alternative to github for repository hosting, with the additional benefit of automatic FTP deployment, and third-party service integration, etc…. I gave their free plan a try, and the service they offer seems to work well…