In Git, anywhere you use a commit ID, like git log or git show, you specify something called a “rev” (short for “revision”) to point to a certain commit. That rev can be a short or long commit ID, HEAD, and many other ones to help you navigate in the history of your repo without having to know or search for an ID.

One of them I learned lately is the “commit message search.”

:/<keyword>

Practically everywhere you use Git with a commit ID, you can replace the commit ID with :/<keyword> instead to use the last commit with the message containing <keyword>. For example git show :/<keyword> or git log :/<keyword>:

# You committed something earlier with "Update top page style":
git add style.css
git commit -m 'Update top page style'

# Later, you want to find that commit again without using the ID:
git show :/style
# Use quotation marks for multiple words:
git log ':/top page' # or
git log :/'top page'

# ⚠️ Note the words are case sensitive!
git diff :/Style..HEAD # ❌ This will NOT find the same commit than above!

# Of course, if you add another commit later with the same keyword,
# that commit will be found instead:
git rev-parse :/style # Commit ID fdf734227f52c3a20debbb0c7b7a085f
git add user.css
git commit -m 'Update style in user.css'
git rev-parse :/style # Commit ID 29a077f5312163f16ee2ff4461447f09

You can read more about revs in the Git docs.

👋 Hi! I'm Rem, a Web developer since 1998, in Japan since 2006. I'm the author of dress.css and Scrollerful. As you can imagine, my experience is varied, including the early days of the Web being a webmaster writing HTML files and scripts in Perl, saved on floppy disks using Notepad, to now being a tech lead for a team, writing CSS with Tailwind or JavaScript for both the backend and frontend in Neovim. I love photography, typography, and colour theory. Strangely enough, my love for print graphic design was what got me into web development. So, yes, I have a few stories to tell and tips to give, and I'm writing some of them, sometimes, here, on RÉMINO Bits.