How to Use Git With FTP
videos

How to Use Git With FTP

Tutorial Details
  • Difficulty: Intermediate
  • Completion Time: 10 Minutes

If you’re not using a PaaS, like Heroku or Pagoda Box, it’s possible that you’re still manually copying files to your server, via FTP. We don’t recommend this, but, understandably, there are smaller and legacy apps that still must be maintained. In this lesson, I’ll show you how to use the DeployHQ service, which allows us to embrace Git-based deployment, while still ultimately using FTP.


Additional Learning

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://aisleb.co.za Constant Meiring

    If you have Ruby installed on your system, you can also install the Dandelion gem to deploy Git repos to FTP incrementally.

    https://github.com/scttnlsn/dandelion

    • http://community-auth.com Brian Temecula

      This seems like a way better solution than DeployHQ.

    • Dimitri Kouvdis

      Agreed!!! Excellent solution.

      Other solution if your host allows ssh, this is more powerful
      http://capistranorb.com/

  • http://7degrees.co.uk Damian Gostomski

    Although I’ve moved beyond using FTP for deploying apps/websites, there are still cases where when building a site/app for a client, the hosting they use doesn’t allow for SSH, so can’t SSH in and pull changes.

    After another such client last week, I found an alternate solution.
    https://github.com/resmo/git-ftp

    This lets you use Git commands (from the console) to push changes to a site over good old FTP, while integrating with Git and only deploying files that have changed.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Yeah, I’ve heard people talk about git-ftp, but haven’t checked it out yet.

    • http://www.josebrowne.com Jose browne

      Much better! This what i’ve used. Works just as expected (uploads only changed files from repo). And of course the best part is price ($0).

  • http://www.stephenradford.me Stephen Radford

    I wanted something similar for Github and BitBucket repositories and my host still refuses to install Git (yeah, I really should look for another one I know).

    I wrote a simple PHP script that uses web hooks to cURL and deploy via FTP on any server.

    http://www.stephenradford.me/blog/tutorials/deploy-via-bitbucket-or-github-service-hooks

  • Alfred Dobradi

    I use Phing since I watched the premium course about it. It’s pretty easy to set up and does the job neatly. Also you can use it to add other useful tasks to the deploy process – such as linting and minifying for example.

    Also Jeffrey, the Pagoda Box link points to wrong url.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Fixed!

  • Oussama

    Hi Jeffrey, Everyone,

    As you sometime in the past recommended the Mediatemple Gridservice I have taken it.
    But I’ve been struggling to get Gitweb working. I’ve been wondering if you’ve had it working,
    and could help me out as nor their support or I know how to get it running.

    I already have git working though, this is the guide I used: http://kb.mediatemple.net/questions/1594/Using+Git#gs

    Thank you by advance,

  • John Veldboom

    Always enjoy your tutorials! I would love to stop using FTP – it’s like a bad habit :(

    But would this not leave a lot of testing commits to your repo? I tend to use FTP to transfer files while I’m working on them and when they’re at a good stopping point or complete is when I start committing the files.

    Is there a simple workflow for small to medium size project to use git to transfer files to a development and then to production server?

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      I guess it depends on how you use Git. It’s more traditional to commit frequently. The basic idea is that, if you can describe the change that you just made to a piece of code, then you should commit it.

  • Jason Smith

    Isn’t it just easier to ssh into your server and git pull?

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Every time?

      • Jason Smith

        Yeah, “ssh serveriphere”, then “cd websitefoler/” then “git fetch”. It does not seem like that much effort really.

  • http://imkreative.com Clemente Gomez

    Im still one of those guys not using a service =(, any recommendations??

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      PagodaBox is pretty good. Not perfect, but the best option right now, I think.

  • http://www.pete-robinson.co.uk Pete Robinson

    This is one approach and great if you love GitHub. If you’re not 100% bought into GitHub, you could use Beanstalk.

    It has this functionality built in (to deploy your GIT/SVN repos to a server) via FTP, SFTP and also SSH. It certainly saves using two different apps for this workflow.

  • http://morointeractive.com Jeff Moro

    A great tutorial. Getting away from FTP would be wonderful, just not sure its a good move for my current work.

  • http://enormail.eu Wijnand

    I start using springloops a year ago and boy it was a blast: http://www.springloops.com/v2/

  • sgobin

    I usually just set up a remote for the production server and use a bash script to automatically run git checkout. After this, just running git push “production server” will copy the files.

  • Chris Sanders

    This is a great topic. Test I was wondering hopefully with more than just php. What can I do to get a node environment going with this?

  • http://dffrnce.tumblr.com nXqd

    Use git-ftp, I have good experience using it :)
    It also has convenience way to fetch from ftp, which is quite useful if you work with someone who don’t use git-ftp.
    https://github.com/resmo/git-ftp

  • http://vos.gr Pavlos Vos

    Hi Jeffrey , nice work

    To be honest i only depoy 1 or 3 times a month for my personal page,

    so i was looking for something alternative

    I just got git-ftp working and it is a work of beauty,
    https://github.com/resmo/git-ftp
    Would you accept a screen cast tutorial ?

  • http://twitter.com/RickHambrook Rick Hambrook

    Git can be used over FTP, why not simply add a second remote repo to push to on the FTP server for these edge cases?

  • ProperCroc

    Problem is, if files change or are added on the remote server (the one you’re ftp’ing to), they will be overwritten by the next git push. An example would be image files uploaded by the users of a website that runs on the remote server.

    Does anybody know a solution to this?

  • Dimitrios Savvopoulos

    Hmm… Good solution but a git pull through a cronjob works fine.

  • Samar Panda

    Fantastic! I will go ahead and update my legacy project with http://www.deployhq.com/