Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display last git commit comment

Tags:

git

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.)

like image 359
whamsicore Avatar asked Sep 03 '11 12:09

whamsicore


People also ask

How can I see last commit message?

Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.

How do you see commit comments on GitHub?

On GitHub, you can see the commit history of a repository by: Navigating directly to the commits page of a repository. Clicking on a file, then clicking History, to get to the commit history for a specific file.

How do I pop last commit?

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits.


2 Answers

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.

like image 175
CB Bailey Avatar answered Oct 09 '22 14:10

CB Bailey


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.

like image 26
Abizern Avatar answered Oct 09 '22 16:10

Abizern