CuTt8: git branch by date

Copper’s Tips & Tricks #8: git branch by date

Here at the office we use feature branches. Feature branches with ticket name/numbers. Now, I am good at remembering numbers, but when I have to switch between different tickets I have no idea which one’s the one I was working on last.

Also, when you use the git branch command, you may be shown a long list of feature branches that can be old enough that you may as well delete it from your local repo.

That would be smart, but it requires thinking.

There’s always a better alternative to thinking: cheating. And this is the cheat I use for git branches:

git() {
  if [[ [email protected] == "branch" ]]; then command git branch --color=always --sort=-committerdate; else command git "[email protected]"; fi;

It’s actually a bash function, because aliases with spaces aren’t supported. So just cat >> that into your .bash_profile file and you’ll be golden.

#TLDR: git branch --sort=-committerdate

Happy git date-branching!

Don’t Stop Here

More To Explore