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.)
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.
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With