My git repository has two branches, \'master\' and \'dev\'.
Code committed to \'dev\' goes through an automated build process before it is tested. Code that passes this
If you're using GitHub, they have a feature to protect branches. Go to the GitHub settings for the repository, then branches and see the protected branches settings.
You can choose which branches you want to protect, and for each branch how you want to protect it. You can just prevent force pushes, require changes to be merged from another branch, or even require that your automated tests have passed.
See https://help.github.com/articles/defining-the-mergeability-of-pull-requests/
Bitbucket offer a similar feature.