TranslateProject/sources/tech/20221024.3 ⭐️ How to display commits created on a specific day with the git log command.md

67 lines
2.5 KiB
Markdown
Raw Normal View History

[#]: subject: "How to display commits created on a specific day with the git log command"
[#]: via: "https://opensource.com/article/22/10/git-log-command"
[#]: author: "Agil Antony https://opensource.com/users/agantony"
[#]: collector: "lkxed"
2022-10-30 17:19:03 +08:00
[#]: translator: "chai001125"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How to display commits created on a specific day with the git log command
======
The git log command is an important reporting tool and yet another reason to use Git.
The `git log` command offers many opportunities to learn more about the commits made by contributors. One way you might consume such information is by date. To view commits in a Git repository created on a specific date or range of dates, use the `git log` command with the options `--since` or `--until`, or both.
First, checkout the branch you want to inspect (for example, `main`):
```
$ git checkout main
```
Next, display the commits for the current date (today):
```
$ git log--oneline--since="yesterday"
```
Display commits for the current date by a specific author only (for example, `Agil`):
```
$ git log--oneline--since="yesterday"--author="Agil"
```
You can also display results for a range of dates. Display commits between any two dates (for example, 22 April 2022 and 24 April 2022):
```
$ git log--oneline--since="2022-04-22"--until="2022-04-24"
```
In this example, the output displays all the commits between 22 April 2022 and 24 April 2022, which excludes the commits done on 22 April 2022. If you want to include the commits done on 22 April 2022, replace `2022-04-22` with `2022-04-21`.
Run the following command to display commits between any two dates by a specific author only (for example, `Agil`):
```
$ git log--oneline--since="2022-04-22" \--until="2022-04-24"--author="Agil"
```
### Reporting
Git has many advantages, and one of them is the way it enables you to gather data about your project. The `git log` command is an important reporting tool and yet another reason to use Git!
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/10/git-log-command
作者:[Agil Antony][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/agantony
[b]: https://github.com/lkxed