Managing git branches and writing commit messages in an easier way

Ibekoros
2 min readMay 3, 2018

There are lots of good articles about how to manage git branches and how to write good commit messages. I’m not repeating the same thing.

Recently I needed an easy way to put some prefix or postfix to my branch name and my commit message.

My specific use case was because of using JIRA issue system. Someone creates an issue ticket and I make a branch for it, develop there and merge it back to master.

So I’ve made a simple CLI tool wrapping git with additional features. It’s called `rlt` . I’ve made an alias to overwrite the original command. Now I just type `git` and everything works the same as before.

Okay, here’s what I’m doing these days.
I’ve been assigned to a new issue named `JIRA-123`.

$ git switch 123

This will switch to a branch named `JIRA-123`. If it’s not created, then it will create it automatically.

And it automatically stashes uncommitted changes including untracked files switching to other branch. When coming back, it automatically unstashes it.

After doing some work, I need to commit it.

$ git cmt
Commiting to 'JIRA-123'
Subject: Fix a bug where user cannot login
Body:
> There was a problem at ……
>

And the commit message will look like the following:

$ git log --onelined9eb113 [JIRA-123] Fix a bug where user cannot login
$ git logcommit d9eb1135f33aa55b6301dfjejcd824654be29522
Author: xxx
Date: Wed May 2 18:56:35 2018
[JIRA-123] Fix a bug where user cannot loginhttp://myjira.com/JIRA-123There was a problem at ……

How is this possible?

With `rlt`, you can configure templates of branch name, subject of commit message and body of commit message.

Simply try install `rlt`:

$ gem install rlt

(not ready yet for brew)

and an alias for it:

$ echo "alias git='rlt'" >> ~/.bash_profile && source ~/.bash_profile

Using templates is described in the git repository.
I hope you find it useful.
Any suggestions are always welcomed.

CHECKOUT -> https://github.com/eunjae-lee/rlt

--

--

Ibekoros

A full-stack software developer living in Singapore. Love coffee & food.