Git for FTP-deployments

FTP and SFTP are a straightforward method as a deployment tool. Git is efficient and relatively easy to get started with so let’s combine these two.

It’s easy to forget, but it is not only the first push of your code and assets that are important, but you also need to make sure that your future updates and bug fixes are quickly deployed too. If you are limited to FTP or SFTP, access much of your time can be spent figuring out what’s changed in your development, and what is needed to be uploaded to the live server. This cycle can be error-prone and tedious.

GitFTP-Deploy is a native MacOS app that transfers only the recent changed files thru SFTP, FTP or FTPS. You may not, depending on your server configuration, have full shell access. The location for the deployments may be on a shared host or a controlled environment. Usually, this means that you don’t have access to command-line tools like git, which is used in many deployment tools.

If this is the case, you are forced to access via FTP or SFTP. The tactics are then to:

  • Track your files in a local git repository
  • Upload and deploy with (S)FTP

More handy aspects of GitFTP-Deploy that can be useful for more complicated projects:

  • Ignore files, files specified in .gitignore will not be deployed. However, you can specify files that will always be uploaded on every deploy. More on this here.
  • Run pre- and post-deployment scripts. In more complex projects you may have SASS or LESS-compilations, Javascript or other build tasks.

Using this method of deployments have its limitations:

  • You cannot modify files directly on the server. All changes have to be made locally, and you have to get into the habit of doing things this way. All changes made on the remote server will put the site out of sync with the repository.
  • This way may not work for large teams, and commits are done thru many different persons. However, GitFTP-Deploy will attempt to check which branch and commit that was last deployed.

This process requires that you have committed all the changes to your repository before deploying. At first, this can be a bit frustrating if you are not used to this workflow. Frequently committing your code and test on the remote server is a good practice.

If your site is powered by a database, you need to check what tools you need to manage database deployments cleanly. My site is powered by Laravel, a PHP-powered framework where database migrations are built in. During deployment, I have configured GitFTP-Deploy to run migration scripts on the remote server.

Many times I am working just myself with I site if find it to be a real time saver just to commit the last changes and everything is pushed onto the server, with a single command. I have auto-deployments enabled in GitFTP-Deploy.

I have developed to ease my deployment process as a web developer over the years. If GitFTP-Deploy is a fit for your projects, feel free to get in touch and let me know if you have any questions.