Moving from FTP to Git deployment, a designer's guide

posted by adam johnson on May 30, 2013

Moving away from FTP and onto Git is pretty straightforward. But what good is moving to Git if you're still using an FTP client to manually transfer files to your server (and thus, taking your files out of version control once more)? This post explains how to move away from FTP deployment, onto Git, and how to deploy straight from your Git repository—all for free. No fancy command-line jujutsu or server side tricks, lots of GUI's, very designer friendly.

Prefer a screencast? Yeah, I thought so:

If you already know Git and don't need any introduction, skip to 9:56.

Why is Git deployment better than FTP deployment?

There's a ton more reasons why using Git for version tracking & deployment is awesome, but you get the picture.

Prerequisites (aka What I'm not going to cover)

You need to know Git (or at least be interested enough to explore), your way around your server (things like connecting via (S)FTP, making directories, and the like), DNS, and all the standard stuff to get a website live on the web. Please note in the screencast I go over how to install and get going with Git, just as a super quick overview; however, I'm not getting super detailed with written instructions. Check the screencast out if you need more Git help.

The tools we're gonna use

Lots of folks have talked about Git and BitBucket before, so I'm not gonna say much about them. Just know that I chose to use BitBucket for this tutorial just because they provide unlimited private repositories for free—something GitHub does not do.

But what about DeployButton?

DeployButton is a relatively new service. Apparently it started as a submission to RailsRumble by the Lizi team. They said it was created because it was something they needed and quickly found out many other people liked the idea too. They wrote a blog post about why they started and what their plans are for the future. Here are some considerations for DeployButton:

Pro's:

Cons:

What else is out there?

While DeployButton is free and pretty cool, it's not the only service like it out there. Here are some others (usually not free):

While most of these services do offer a free plan (usually a trial or for one project), it's unlikely that you'll be able to utilize their free plans due to their project limitations.

Update 8/21/13: Over the past few months, I've had some issues with Deploy Button. If you're serious about deploying your project, I'd look into one of the services listed above. That said, YMMV.

Step by Step:

Okay, so we've covered some of the options and considerations, let's do this!

1. You gotta know Git to start using git. You have two routes here:

2. Sweet, you know Git. Now create the repo you'd like to deploy. Considering we're still on the free train, you can put it on GitHub if you want it to be public, or you can use BitBucket to keep it all private and secret like. Create the repo, add some files, commit, and push. If you're super lazy, you can fork someone else's code and bring it under your masterful control. See the screencast if you need help and check out my instructions for sorting the notorious "Permission denied (publickey)" error.

3. Now, let's deploy all the things! Setting up your details with DeployButton is stupid easy. Connect your account with BitBucket and GitHub—even DropBox if you fancy that route. After that, you give it the same credentials you give your (S)FTP client. Shoot, you can copy and paste if you like (it'll look something like this). During this process, be sure to make a folder with your favorite (S)FTP client that you'll deploy to. Then hit that giant red "DEPLOY" button. Watch the magic happen (DeployButton will connect to your server and BitBucket, get all the codez, and deploy). After all is said and done, double check via (S)FTP that your files made it up to the server.

4. Congrats! You just moved your stuff to Git and deployed it to your server. Not too hard, right?

You should note that, while DeployButton does use Git, Git itself doesn't have to be installed on your server—which is super handy for those readers on shared hosts. It means Git stays with your local machine along with GitHub/BitBucket/etc. Your production server has no specific Git-based requirements in order to make this happen. Nifty.

Some error bringing your world down?

Learning Git is gonna be a bumpy road. Keep yer' head up, kid. After that, Google it. Someone has definitely run into the same problem you're seeing—and figured out how to fix it. There is always hope. As I mentioned before, a super common error is Git not being able to push to GitHub/BitBucket/etc due to a Permission denied (publickey) error. Here's instructions on how to create a publickey and add it to GitHub/BitBucket.

Should I track the core of my CMS?

This is somewhat personal preference; however, be aware that the "core files" for whatever CMS you're using (Concrete5, Wordpress, Drupal, et cetera) likely have a metric shit-ton of files in them. That means, if you choose to track the core of your CMS, everything you do will take longer (think git status, git add, git push, et all). Thereby, to start, it's probably a good idea to look into making a .gitignore file and ignoring the core of your CMS for your Git repo.

Earlier, I mentioned how this is not the only option. While this may be the easiest (?), DeployButton could one day spontaneously combust, leaving you in the lurch. I plan to write a blog post about Ryan Florence did a wonderful job explaining how you can roll your own system for Git deployments. For now, grab a beer, celebrate moving to Git, and pat yourself on the back for being more awesome.

Update 8/21/13: Chris Coyier wrote a great roundup about the many ways you can tackle deployment. It's worth a look.

If you have other resources on deployment, let's hear them in the comments! Extra points if they are wicked simple and well documented.

blog comments powered by Disqus