Gaiety's visual representation as a fursona (an original furry fandom character) depicted as an animated gif falling downward with a controlled hand outstretched. Faer hair and tail waves in the wind while their floppy dog ears flop about as well. Fae are an anthromorphic canine like a german shepherd clothed like a human in a t-shirt and denim shorts. Art is by Lynte.

Easy Git Commit Targeting in Posts

Shortened SHA hashes and relative offsets

A generally agreed upon goal of a developer is to use the mouse as little as possible. An often overlooked moment of touching the mouse is the seemingly inevitable moment of having to target a git commit via it's SHA hash. Truth is this doesn't need to be an ordeal.

Let's look at some alternative ways to target commits.

By Shortened SHA Hash

Traditionally to find the git diff 123abc456def789ghi on a SHA you'd use the entire SHA hash. Instead, you can type just the first few characters and Git will figure out the rest.

git diff 123abc
bash

Tilde

A common target is the previous commit from the HEAD. Using HEAD~ will specify the intention of one commit before the HEAD.

git diff HEAD~
bash

Past Tilde

Adding a number after the tilde ~ will target a commit prior to the head equal to the number specified.

git diff HEAD~3
bash

Stacked Carets

Alternatively, the number of caret characters after HEAD will similarly target a commit prior to HEAD equal to the number of carets.

git diff HEAD^^^
bash

Combine These Tricks

So close! Ever want to target the commit just previous to a SHA hash? It's easier than you think.

git diff 123abc~
bash

Summary

Through a combination of shortened SHA hashes, HEAD, and relative tilde/caret characters anyone can fly through git history with confidence.

ava@wroten.me

Wish to contact me about meetup or conference talks, work opportunities or otherwise? Reach out to me via email.

Resume

Work history, skills, volunteering and talks given all in a one page PDF.

Blog

Programming, art, design, and other queer things.

Git

Coding projects and such on a self hosted Forgejo instance.