📅  最后修改于: 2023-12-03 14:41:26.526000             🧑  作者: Mango
In Git, the 'git log' command is used to display the commit history of a repository. With this command, you can view information about each commit such as the commit message, author, date, and time. Moreover, it is possible to limit the amount of information displayed by adding various parameters.
In this article, we will show you how to use the 'git log' command to show the last n commits of a Git repository using Shell/Bash.
The basic syntax of the 'git log' command is as follows:
git log [options] [<revision range>] [[--] <path>…]
where:
To show the last n commits of a Git repository, you can use the following command:
git log -n <n>
where:
This command will display the commit history of the repository, starting from the most recent commit and going back n commits. By default, the output will show the commit hash, author, date, and commit message of each commit.
There are several options that can be used with the 'git log' command to customize the output. Some commonly used options are:
For more options, you can refer to the Git documentation.
In this article, we have shown you how to use the 'git log' command to show the last n commits of a Git repository using Shell/Bash. With this command, you can view information about each commit, limit the amount of information displayed, and customize the output using various options.