Display last git commit comment
git show
is the fastest to type, but shows you the diff as well.
git log -1
is fast and simple.
git log -1 --pretty=%B
if you need just the commit message and nothing else.
Generally:
git log -n
will show you the last n
commit messages
More elegantly - if you want a quick overview of your commits
git log --oneline -n
This will show just the first line of the last n
commit messages.
You can save this as a git alias or a shell alias with a shorter command. I've got it in my shell as glog
, for example, and I can see my last 10 commit messages with glog -10
.
You can use
git show -s --format=%s
Here --format
enables various printing options, see documentation here. Specifically, %s
means 'subject'. In addition, -s
stands for --no-patch
, which suppresses the diff content.
I often use
git show -s --format='%h %s'
where %h
denotes a short hash of the commit
Another way is
git show-branch --no-name HEAD
It seems to run faster than the other way.
I actually wrote a small tool to see the status of all my repos, including the edit status, the relation to remote branch, etc. It also batch executes commands from any working directory.
You can find it on github.