Deploying with FTP:

    Deploying your project with FTP


    FTP (File Transfer Protocol) is traditionally one of the most famous way to deploy static HTML or PHP websites, because of its simplicity and low cost of service.

    SourceLair makes it extremely easy to deploy your Git-powered HTML and PHP projects using FTP with its built-in support for git-ftp. Git-ftp is a command line tool that uses Git in order to transfer only the updated files since the previous deployment to the server.

    Worth to mention is that git-ftp does not require Git to be installed on the remote server.

    This guides requires the following in order to get started:

    • An active SourceLair account - sign up
    • A Git-versioned PHP or HTML project

    Are you ready? Let's make our first deployment.

    Your first deployment

    Deploying with FTP from SourceLair is as simple as running a single command. Open the Command Palette with Ctrl + Shift + P (or Cmd + Shift + P if you are on a Mac), type ftp in the input field and hit Enter when the command Git-ftp: Deploy gets selected.

    This should start the Deploy process in your terminal. Since this is the first time you are deploying with git-ftp, it will ask you for your FTP username, password and host and store them in git-config. After entering your details git-ftp will initialize the remote directory and upload your files there.

    The next time you will attempt to deploy git-ftp won't ask for each information, since it has stored them in git-config and will move forward with deploying your changes.

    Attention: Make sure to commit all uncommitted changes before deploying with FTP, because git-ftp will refuse to deploy any uncommitted changes.

    Now that you completed your first deployment, what about securing it?

    Securing your deployment with SFTP

    Despite the easiness of use and its low-cost, FTP comes with its drawbacks as well. The first and most important is that FTP is an insecure protocol, thus it cannot guarantee on its own that your data won't be stolen or intercepted during transfer.

    This is where SFTP (SSH File Transfer Protocol) comes in. SFTP uses SSH to encrypt the whole traffic end to end, from client to server. Thankfully most FTP providers provide support for SFTP transfer as well and Git-ftp supports the SFTP protocol out of the box.

    To use SFTP as your deployment protocol at your first deployment as described in the previous step, just enter your FTP host in the following form when asked: sftp://myftphost.

    Setting up password-less deployment

    Some SFTP providers let you set up password-less deployments by setting up a private/public RSA key pair. Password-less deployments are the best choice when deploying with FTP, since they provide great security while you do not have to remember any password.

    To do this you should follow the instructions of your SFTP provider and add your SourceLair public key to your remote server. You can find your public key at

    Attention: You have to enable SFTP manually on SourceLair. To do this follow the instructions here or run the following command in your terminal:

    curl | bash

    Now let's see how we can deploy a subdirectory of our project.

    Working with subdirectories

    There are cases where the developer wants to publish only a subdirectory of their project and the hosting provider demands the files to be placed in a particular subdirectory. Git-FTP is here to cover both cases and their combination.

    In order to deploy a particular subdirectory of your project, run the following command in your terminal, after replacing sub/directory with the actual subdirectory that you would like to deploy.

    git config git-ftp.sourcelair.syncroot sub/directory

    To deploy your project to a particular directory to your hosting provider, run the following command, after replacing /remote/path with the actual path that you would like to deploy to.

    git config git-ftp.sourcelair.remote-root /remote/path

    As mentioned above these settings can be used together as well. Just run both commands and everything should work out of the box.

    The next step is to learn how to deploy to staging and production environments.

    Deploying to multiple targets

    As applications grow larger, usually there is need to test them in multiple environments before deploying to production. Git-ftp covers this case as well by providing users with the ability to deploy to multiple scopes.

    To configure a new scope you have to run the following commands in the command line:

    git config git-ftp.scopename.user yourusername
    git config git-ftp.scopename.url your.ftp.url
    git config git-ftp.scopename.password yourpassword

    Now you can deploy at this remote at any time by running the following command

    git ftp push -s scopename

    You are all set! Let's recap now.


    By finishing this guide you have learned how to combine the best of two different worlds; the simplicity and low-cost of deploying with FTP and the security and robustness of a Git repository.

    Git-ftp is a powerful command line tool whith lots of functionalities and customization options. If you would like to learn more about git-ftp and its advanced usage, take a look at its page at

    Do you believe that we can improve this guide? We would love to hear your suggestions at

    Do you have an HTML or PHP project and would like to deploy it frictionlessly? Then lose no more time and head at