I am Drew Yeaton

and I design standing up.

0 notes

Poor Man’s Guide: Deployment with Git (and GitHub)

Git is one of those things that when you learn it, you start looking for reasons to use it. I would describe it as frictionless version control. Although the king of nerdy, abrasive verbosity, Linus Torvalds explains it as really just a filesystem—it’s the way that you use it, through its minimal, command-line interface that makes Git so efficient.

The technical stuff I’m not great at, so use the these guides for installation. Also, check out this radical guide for getting started.

So, I use Git for all my personal projects and a few things at Flipswap. But, occasionally I have a need to deploy my work to a live server. I have a GitHub account so my hosted repository needs are taken care of, but I have yet to see a simple script that outlines how you’d actually do a deployment with Git. In hindsight, that’s probably because it’s so easy. Take a gander.

I have a shell script in a directory outside of my httpdocs directory called “private”. The script pulls in any updates from the repo hosted on GitHub into my “site” directory (which is below the “private” directory). Then copies everything sans hidden files (including the actual git files) to my “httpdocs” directory. The script looks like this:

echo “Updating…”
cd site
git pull
echo “Copying…”
rm -rf ../../httpdocs/*
cp -rf * ../../httpdocs/
# do any permission changes here…
# chmod 777 ../../httpdocs/system/cache
echo “Done.”

Filed under programming poor man's guide git