Often during a commit ($ git -commit -m ""), I wish to read my last comment to remember what progress I have made. Is there an easy way to directly access the last commit message through command-line? (I'm using Windows.)

share|improve this question
If it is a regular action, make an alias (e.g. wherewasi ;-) for your chosen solution / command line. You could include the branch info as well. – Philip Oakley Sep 3 '11 at 15:16
up vote 381 down vote accepted
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.

share|improve this answer
(on ubuntu) the line is truncated if it does not fit in the shell. Any idea how to make it print a multi-line message? – Juh_ Nov 14 '14 at 9:14
the %B format was what I needed to not have the commit message indented. And yes, @Juh_, even though git gui doesn't linewrap for you, it's a good idea to use 80column text in commit messages, not line-per-paragraph. – Peter Cordes Dec 13 '14 at 1:06
@Juh_ You can show the whole message by using git log -1 --pretty=%B | cat, but as Peter said, you should try to keep it to 80 characters. – Ruckus T-Boom Jan 20 '15 at 22:32
@Juh_ this is a bit too late but if you want the commit message to line-wrap, just pipe the output to cat i.e: git log -1 --pretty= | cat – kosgeinsky Jul 27 '15 at 14:51
Someone looking for more information on the percent-placeholders, see: kernel.org/pub/software/scm/git/docs/… (scroll down to format:<string>). – immeëmosol Jul 31 '15 at 15:36


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.

share|improve this answer
thanks for --oneline I was looking for that one – Jacek Wysocki Feb 7 '14 at 13:20
nice and easy to remember – PrimeLens Jul 10 at 20:57

git log -1 will display the latest commit message or git log -1 --oneline if you only want the sha1 and associated commit message to be displayed.

share|improve this answer
What about the same in mercurial? – Nevin Raj Victor Aug 6 '15 at 6:38

git log -1 branch_name will show you the last message from the specified branch (i.e. not necessarily the branch you're currently on).

share|improve this answer

For something a little more readable, run this command once:

git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"

so that when you then run:

git lg

you get a nice readout. To show only the last line:

git lg -1

Solution found here

share|improve this answer

I did this

git reflog -1 | sed 's/^.*: //'

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.