Git, see a list of comments of my last N commits
Is there a way to see a list of comments and time of my last N commits in Git?
After looking on SO, the only relevant thing I have found is Git - get all commits and blobs they created, but it shows all commits from all users, and outputs a lot of other information.
If you want to use the command line you can use the --author=<your name>
For example: to see your last 5 commits
git log -n 5 --author=Salvador
If you want a simpler one line solution:
git log --oneline -n 5 --author=Salvador
Edited to add
If you like the single line version, try creating an alias for git log
like this (this is what I have for zsh)
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Now, I can just use:
glog -n 5
And I get a nice output such as:
Which is colourised, shows the name of the author and also shows the graph and you can still pass in other flags (such as --author) which lets you filter it even more.
Use the --author
and/or --committer
filtering options with git log
, plus the -n
option to limit the number of commits. For example:
git log --author='Salvador Dali' -n 10
git log --format="%h %B" --oneline -n 1
This will get you latest git log comment block with abbreviated commit id.
git log --format="%H %B" -n 1
This will get you latest git log comment block with full commit id.
You can build your own format from : Git Pretty Format
git log --author="My name" -n 5
(see man git-log
for all alternatives)
See a list of comments of last N commits
git log --oneline -10
Check out to an older commit
git ckeckout 3e6bb80
Get back to the latest commit after checking out a previous commit
git checkout -