A Productive Git Workflow

Since git is an integral part of my development life cycle and I spend quite sometime committing things to it, I always felt there was something missing, until I did my Android Nanodegree at Udacity where I learned about structured commits.


Why structure your commits?

  1. Keeps your git history neat & meaningful.
  2. Easy to generate change logs

Lets look at how I structure my commits.

The Commit Prefixes

  • feat — a new feature
  • fix — a bug fix
  • docs — changes to documentation
  • style — formatting, missing semi colons, etc; no logical code change
  • refactor — refactoring production code
  • test — adding tests, refactoring test; no production code change
  • chore — updating build tasks etc; no production code change

But you’ll be wondering how is it productive when you have to type those tags into each commit message.

So here’s a script you might want to see

https://github.com/ishan1604/productivity/blob/master/commit

Just put it into your PATH and access it easily like so

$ commit feat

So now when I do

git log --oneline --decorate --graph

Here is what it yields

This is just half the fun

Now when I want to generate a change log, I have a python script that picks up all the commits with the tags feat or fix to generate a change log for me.

Here is the python script

https://github.com/droidchef/productivity/blob/master/commit

So the output of the python script looks something like this in a change-log.json file

{  
"features":[
"feature 1",
"feature 2",
"feature 3"
],
"fixes":[
"fix 1",
"fix2",
"fix 3"
],
"major":0,
"minor":9,
"patch":11
}

You can then use this to easily curate your CHANEGLOG.md or tell your boss what you did over the last X days.

You can change this variable in the python script on line number 14 to generate the change log from the date you want

afterDate = '2016-09-12'

I’ll be adding more productivity related stuff to it soon. Till then you can give some love to the repo.

https://github.com/droidchef/productivity/

Loading comments...
You've successfully subscribed to Ishan Khanna
Great! Next, complete checkout to get full access to all premium content.
Error! Could not sign up. invalid link.
Welcome back! You've successfully signed in.
Error! Could not sign in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.