Sunday April 30, 2017
At 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 --firstname.lastname@example.org --pretty' $ git config --global alias.my-freeze 'rev-list origin/freeze ^origin/prod --email@example.com --pretty' $ git config --global alias.my-prod 'rev-list origin/prod --firstname.lastname@example.org --pretty --after="14 days ago"'
Using them is easy!
$ git fetch $ git my-freeze commit bebba3afb108719bbdc500cb3dce50ffc062f060 Author: Mike Kasberg <email@example.com> Date: Sun Apr 30 13:15:15 2017 -0600 Write more code... Make another commit commit 00a54a1d6cc80a7103389bc813c6d76c2014cd85 Author: Mike Kasberg <firstname.lastname@example.org> 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 --email@example.com --pretty'
With a little customization, you can make an alias like this to help out with your own projects.
Did you like this blog post? Why not share it with your network!