August 8, 2013

Using Git: Taking the Pain Out of Version Control

I love elegance, purity and simplicity

In the 90’s as a rookie developer, I spun my wheels… a lot. With no true version control, we would update the production server directly. Then, weeks or months into the project, we would spend the time to set up a dev server. Our team would do their best to wrangle the process of developing locally, updating a dev server, and when everything was tested we would update everything on the production server and pray everything was put into place correctly. But we often wrote over each other’s code and our only saving grace was a nightly server tape backup. I would keep local copies of different versions of folders and files: index.php.bak1, index.php.bak, index.php.final, index.php.final2 (how many times did I think this was going to be the final version of this page? Too many to count.) These were dangerous times, and had some dire consequences, and I wasted a lot of resources.

Along came SVN and it made my life less stressful. I created our repositories for the team and loaded everything into TortoiseSVN. I tolerated the .svn files and directories created throughout our project. And before pressing the button, we would lay an offering at the altar of “merge”‚ hoping the gods would smile down on us. More often than not, a bolt of lightning would strike us down and we would have to back out, make changes, and try again.

We were never fully successful at setting up deployments to the production server. I’m smart about some things, but with so many layers of complexity it was just easier to ftp files into place.

Today’s process is so much simpler, safer and elegant.

We now use Beanstalk, a version repository hosting service. They still support svn if you need it, but Git has taken over as everyone’s version control of choice and for good reason.Git gives us the simple elegance of editing locally and pushing to development or production when your code is ready for prime-time.

How does it work? (source)

In Beanstalk, FTP/SFTP deployments work as a synchronization tool. After the first deployment Beanstalk will check for changes in the most recent revision of your repository to the one on the remote server. It will then upload those changes to the remote server, which makes it extremely fast to keep everything up to date. Beanstalk will add, edit and remove files as they were added, edited and removed in the repository.

You can trigger a deployment in three ways:

  1. Automatically each time a commit or push is made in the repository.
  2. Manually in your Beanstalk account.
  3. Adding a tag to any commit or push comment like [Deploy: Staging]

If you are deploying manually, Beanstalk allows you to select any revision in the repository. This way, you can choose an older one to rollback in case of any problems introduced in a recent deployment. If you are using SSH deployment, we’ll simply run the shell command you enter on your settings page whenever a deployment is triggered. These can be triggered in the same three methods as FTP/SFTP deployments.

Beanstalk

What Beanstalk has done better than anyone else I’m aware of is make the deployment to your development and production servers painlessly simple. After you push changes to your repository, it can SFTP into your site, update the files that change, and even execute other commands or post back to a web hook when complete. We have it clear the cache directory after every push – a lifesaver for heavily cached systems like Magento. It takes a few minutes to set up, and will save you tons of time and resources. Resources:

Paul Weinert
Author

Paul Weinert is our founder, managing principal and spirit animal. He’s one of those odd people you meet that was born in Portland, grew up here and still lives here for some reason. If you had two words to describe Paul after meeting him, we’d bet you’d use “charmingly quirky”.

Paul started GRAYBOX in February 2009, and for the first four years, GRAYBOX had a blend of a contract staffing firm and a traditional agency. GRAYBOX then hired our first employees in 2012 and has been growing ever since. Professionally, Paul has a background in internet business consulting, working especially with mid-market ecommerce, healthcare, and tech companies. He worked as a user experience designer, web developer and internet marketer. Nowadays, Paul serves as our company visionary, team mentor and head of executive leadership — Paul is extremely proud of the entire team and the company. He’s constantly humbled by the team’s awesomeness and the caring community that’s sprung up from his initial ideas.

Beyond GRAYBOX, Paul is married, has two young boys and lives in NE Portland. He’s also an active foster parent, mentors other local entrepreneurs, and volunteers on local non-profit boards. Businesswise, aside from GRAYBOX, Paul has started a few other businesses and is an active investor in the local startup scene.

For the sheer joy of it, let’s play 2 truths and a lie:

  1. Paul firmly believes that any activity would be better if on a boat.
  2. Other than this whole Internet thing, Paul has basically no other skills or expertise in anything.
  3. Paul is rare unicorn, actually born and raised in Portland.