I usually use Git log commands to check changes in my plugins and themes. While some app like SourceTree does that job very well, I prefer command lines in some situations. Here are some git log commands that I use quite a lot.
Common Git Log Commands
1. Show list of commits
git log --graph --oneline
If you use zsh, you can simply use
glol
2. Show only file names in commits
git log --graph --oneline --name-only
3. Show full commits
git log -p
If you use zsh, you can use
glgp
4. Show git log of a specific commit
git show ac29810
Sometimes, it's hard to copy the commit reference. So you might want to use relative reference. Here are some tips:
Just use:
HEAD^
to get the second last commitHEAD^^
to get the third last commit on branchmaster
.HEAD~10
to get the 10th last commit
They can even be combined: HEAD^^~5^
.
HEAD
can be any branch name (local or remote). You might also want to use code>@</code instead of HEAD
which give the same result.
5. Show the change history of a file
git log --graph --oneline [filename]
6. Show change of a file in a specific commit
git show ac29810 [filename
Beautiful Git Log
I remember when I used to use zsh
that has a Git plugin. The plugin has some Git aliases that show the log beautifully. So, I decided to do the similar thing with git log
only. And I found this post and this post. So I decided to make a combination of them:
Just run these commands below to add 2 git aliases:
git config --global alias.l "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
git config --global alias.ls "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --all --find-copies -M --stat
And here is what you have:
Output of git l
:
Output of git ls
:
Leave a Reply