Featured image for TWIL blog post on Git aliases, showing a simplified illustration of branch management and code snippets.

Welcome to TWIL, your weekly source for software development tips and tricks. In this installment, Katie shares some of her favorite Git aliases, teaching us how to streamline our workflow with powerful shortcuts for branch searching and recent branch tracking. Her examples are efficient techniques to keep your repository exploration both nimble and insightful. Join us in embracing these time-saving commands and hone your Git prowess with every commit!

Git aliases: Branch Search and Recent Branches

Search a branch by name by piping the output of git branch to grep:

# get the branches that match the given pattern
branch-search = !git branch | grep --color=always
brs = branch-search

Usage example:

$ git brs bug
* bug -branch
  bug/another-bug 
  bug/fix-thing-a 
  bug/search-for-bug-branches-example

recent-branches (or brecent)

Show the most recent branches (number determined by --count flag, set to 7 here), sorted by most recent commit.

# get the most recently-committed branches
recent-branches = "!git for-each-ref --sort=-committerdate refs/heads --count=7 --color=always --format='%(color:black)%(committerdate:relative)|%(HEAD)%(color:green)%(refname:short)|%(color:white)%(subject)%(color:reset)' | column -ts'|'"
brecent = recent-branches

Usage example:

$ git brecent
75 seconds ago         *bug-branch    Most recent commit
24 hours ago           master         Add nice new git branch search and sort aliases
2 weeks ago            test2          Commit #2
1 year, 1 month ago    git-fns        WIP
1 year, 1 month ago    test           WIP
1 year, 3 months ago   work           WIP

The --format flag can also be adjusted to display the output as desired. As it is, it will output:

  • The time since the most recent commit (black) : %(color:black)%(committerdate:relative)
  • Asterisk indicating current branch (black) : %(HEAD) *
  • The branch name (green) : %(color:green)%(refname:short)
  • The message of the most recent commit (white) : %(color:white)%(subject)

Each section is separated with a |, and the output is then piped into column -ts'|' for column alignment where the | characters are.

*This is black because it follows the previous %(color:black) and precedes the following %(color:green), but it appears ahead of the branch name because it is placed after the | separating the commit date output and the branch name output

Resources

  • git
Katie Linero's profile picture
Katie Linero

Senior Software Engineer

Related Posts

MCP (Model Context Protocol) logo — a stylized white interlinked letter mark — centered on an abstract background of flowing purple and orange gradient waves, representing AI connectivity and data integration.
November 25, 2025 • Frank Valcarcel

Anthropic’s Model Context Protocol: The Standard for AI Tool Integration

A year after launch, Anthropic’s Model Context Protocol has become the universal standard for connecting AI agents to enterprise tools. Backed by OpenAI, Google, Microsoft, and the Linux Foundation. Here’s what developers need to know.

Glowing teal React atom logo on a dark background featured image for a guide to every use directive, hook, and API in React 19.
January 7, 2025 • Marisa Gomez

The many uses for use in React 19

React 19’s relationship with the word use has reached the point where you could write an entire component and the only English word in it is use. We break down every flavor of use in React 19 and when to reach for each one.

Let's work together

Tell us about your project and how Cuttlesoft can help. Schedule a consultation with one of our experts today.

Contact Us