
When's My Code Going Out?
30 Apr 2017At SpotX, we manage our codebase with Git. Our commits flow from our develop branch to production, with a code-freeze branch in-between. Like this:
With any web application, it’s really important for developers to know when their code is going out. So they want to know which branch it’s on. To help with this, I created a few simple git aliases that show recent commits a developer has made in any branch. Here are the commands to create them:
$ git config --global alias.my-dev 'rev-list origin/develop ^origin/freeze --author=mike@mikekasberg.com --pretty'
$ git config --global alias.my-freeze 'rev-list origin/freeze ^origin/prod --author=mike@mikekasberg.com --pretty'
$ git config --global alias.my-prod 'rev-list origin/prod --author=mike@mikekasberg.com --pretty --after="14 days ago"'
Using them is easy!
$ git fetch
$ git my-freeze
commit bebba3afb108719bbdc500cb3dce50ffc062f060
Author: Mike Kasberg <mike@mikekasberg.com>
Date: Sun Apr 30 13:15:15 2017 -0600
Write more code... Make another commit
commit 00a54a1d6cc80a7103389bc813c6d76c2014cd85
Author: Mike Kasberg <mike@mikekasberg.com>
Date: Sat Apr 29 11:16:44 2017 -0600
Write some code... Make a commit
This is a really simple way to use a git alias to make branch management a little easier. With slight modification, it will help with pretty much any branching strategy - for example, you could get a list of commits written by you on a feature branch that are not yet in master:
$ git config --global alias.my-feature-commits 'rev-list origin/feature ^origin/master --author=mike@mikekasberg.com --pretty'
With a little customization, you can make an alias like this to help out with your own projects.