brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git log with grep searches your commit messages, add -i to ignore case

Git
~/tips/tip-git-log-grep-commit-messages

git log --grep="login" -i --oneline

Finds commits by words in their message instead of by the code they changed.

Searching code changes is what -S and -G do. When you remember the message and not the code, search the messages themselves.

git log --grep="login" -i --oneline

--grep takes a regular expression and matches it against the commit message. -i (or --regexp-ignore-case) makes it case insensitive, so Login, LOGIN and login all match. Ticket numbers are a good use for this:

git log --grep="#1234" --oneline --all

You can give --grep more than once. By default a commit matches if any of them hits. Add --all-match and a commit has to match every pattern, which is how I’d narrow a search down to “fix” commits that also mention the cache:

git log --grep=fix --grep=cache --all-match --oneline

There’s also --invert-grep, which shows the commits whose message does not match. That’s a quick way to hide all the “WIP” noise.

The search only sees what people wrote. A repository full of messages like “update” or “changes” won’t give you much, and squash merges often put the useful text only in the merge commit. In that case search the code with git log -S instead.

Further reading: git-log documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link