Git log filtering and how to show a better history tree
Arturo Linares
Posted on May 29, 2020
Some useful commands to find commits using Git:
Filter by content
Filter by the contents of a commit. Think of it as if you do a git log -p
(shows the diff of each commit) and then you search the output.
git log -S var_dump
Filter by commit message
git log --grep "FRB-666"
Filter by author
git log --author "Arturo"
You can use emails and several values:
git log --author "outlook.com|hotmail.com"
Filter by date
Conveniently accepts --before
and --after
git log --before "2017-06-11"
Git log format
I've found that git log
is powerful, but sometimes difficult to read. Normally I use this git alias to show a nice tree in the console:
$ git config --global alias.lg
log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit
This will show a tree like this when you type git lg
Posted on May 29, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.