Simple Git Deployment

By Ryan Florence, published 2010-07-27

Part of the issue Git Your Act and Deployment Together.

If you’re still using FTP to deploy websites, knock it off. Here’s a simple way to use git to deploy web sites and applications.

You have three repositories: remote, local, and web server. Push from local to remote, clone the repository on your web server, and then simply pull updates after you push.

  1. Local Machine: Push your local repository to a remote server. Check out git for beginners if you’re lost already.

     $ git remote add origin git@github.com:rpflorence/example.com.git
     $ git push origin master
    
  2. Web Server: Clone the remote repository on your web server. You’ll need ssh access to it.

     $ ssh rpflo@ryanflorence.com
     $ cd public_html
     $ git clone git@github.com:rpflorence/example.com.git
    
  3. Local Machine: Make changes to your local repository.

     # make changes in your local repo
     $ git commit -a -m 'Added cool stuff'
     $ git push origin master
    
  4. Web Server: Pull the changes from the remote repository.

     $ ssh rpflo@ryanflorence.com
     $ cd public_html/example.com
     $ git pull origin master
    

    Deployed!

I like this method because there is no real “setup,” it’s completely straightforward: clone the origin repository, pull updates from it, done. It’s not wearing fancy pants, it is simply git at its finest. For a method that is wearing fancy pants check out deploying websites with a tiny git hook

Hi, I'm Ryan!

Location:
South Jordan, UT
Github:
rpflorence
Twitter:
ryanflorence
Freenode:
rpflo

About Me

I'm a front-end web developer from Salt Lake City, Utah and have been creating websites since the early 90's. I like making awesome user experiences and leaving behind maintainable code. I'm active in the JavaScript community writing plugins, contributing to popular JavaScript libraries, speaking at conferences & meet-ups, and writing about it on the web. I work as the JavaScript guy at Instructure.