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

How to output git log with the first line only?

1个答案

1

You can achieve this by using the git log command with additional parameters to display only the first line of the Git log. Specifically, you can use the -n parameter to limit the number of log entries output. For example, to view the most recent commit, you can use the following command:

bash
git log -1

Here, -1 specifies that only the most recent entry should be displayed. If you want more detailed output, you can combine it with other parameters, such as --pretty=format:"%h - %an, %ar : %s" to customize the output format, which includes the commit hash, author name, commit date, and commit message. The command would be:

bash
git log -1 --pretty=format:"%h - %an, %ar : %s"

This will produce a concise single-line log entry containing key information, which is very useful for quickly retrieving the latest commit details in daily work.

2024年6月29日 12:07 回复

你的答案