乐闻世界logo
搜索文章和话题

How to check the last commit in git

1个答案

1

To view your last commit, you can use Git's git log command, which displays the commit history and can be customized with various options to show specific information. For viewing the most recent commit, use the -1 option, which shows only the latest commit.

The specific command is:

bash
git log -1

This command displays detailed information about the most recent commit, including the commit hash, author, date, and commit message.

Additionally, if you only want a summary of the most recent commit, use:

bash
git show --summary

For example, suppose I am responsible for adding new features to a project. After completing the feature development, I commit. To confirm and view the details of my commit, I use git log -1. This command outputs something like the following:

shell
commit 3a1b2c4d5e6f798087654321abcd1234ef56789g Author: Your Name <your.email@example.com> Date: Thu Mar 4 21:00:00 2021 +0800 Added new payment functionality

This way, I can clearly see that my last commit involves adding new payment functionality, including its commit hash, date, and author information.

2024年8月8日 09:34 回复

你的答案