# Git commit message search rev

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>`:

```sh
# 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](https://git-scm.com/docs/gitrevisions).
