Git log filtering and how to show a better history tree
November 4, 2019ā¢163 words
Git log filtering and how to show a better history tree
git
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:
bash
$ git config --global alias.lg
log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
This will show a tree like this when you type `git lg`<br>
<br>
![Terminal with git log tree](https://i.snap.as/nusqCYO.png)