Git-based deploys
Posted on 21 May 2012 by Nick Boyce. Find me on Google+
Recently we’ve switched from FTP to git to deploy changes to our live sites. Here’s what our workflow looks like for functional changes (content amends use steps1,2,5,7,8):
- Make changes on VMs on develop branch
- Commit and push develop branch to Github
- Pull develop branch to staging server
- Review changes
- Merge develop into master
- Run Selenium tests
- Push master to Github
- Pull master into live server
By using a Git-centric workflow, it’s easier to guarantee that each application is running the same code, and we have the added safety of being able to roll back to previous versions.
Pulling changes onto live websites with millions of daily visitors makes me a little nervous, so I’ll usually use git fetch rather than git pull, like so:
$ git fetch
Pulls the remote master branch into a branch in the local repository called origin/master.
$ git diff --numstat master origin/master
Reports the affected files between master and the origin/master branch we pulled in the previous step.
$ git merge master origin/master
Merges the origin/master branch into master.