6

用 git log 命令显示在特定日期的提交记录

 1 year ago
source link: https://www.51cto.com/article/722141.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

用 git log 命令显示在特定日期的提交记录

作者:Agil Antony 2022-11-06 20:40:24
git log 命令是 Git 中一个很重要的查看提交记录的工具,它也是人们喜欢使用 Git 的原因之一。
e30115736a67f9d690108894b60b76ad425639.jpg

​git log​​​ 命令能够让你了解到更多关于贡献者 提交commit 的记录。使用 ​​git log​​ 的一种方式是按日期查看提交记录 。要查看在指定日期或日期范围内创建的 Git 存储库中的提交记录,请使用带有选项 ​​--since​​​ 或 ​​--until​​​ 或者同时使用以上两个选项的 ​​git log​​ 命令。

首先,进入你要查看的分支(例如,​​main​​ 分支):

$ git checkout main

接下来,你可以使用以下命令,来显示当前日期(即今天)的提交记录:

$ git log --oneline --since="yesterday"

仅显示某一特定用户(例如,用户 ​​Agil​​)在今天的提交记录:

$ git log --oneline --since="yesterday" --author="Agil"

还可以显示在某一日期范围内的提交记录。使用以下命令,显示在任意两个日期之间(例如,2022 年 4 月 22 日至 2022 年 4 月 24 日)的提交记录:

$ git log --oneline --since="2022-04-22" --until="2022-04-24"

在上面这个例子中,会输出 2022 年 4 月 22 日至 2022 年 4 月 24 日期间,不包括 2022 年 4 月 22 日的所有提交记录。如果你想要包括 2022 年 4 月 22 日的提交记录,请将命令中的 ​​2022-04-22​​ 替换为 ​​2022-04-21​​。

运行以下命令,能够显示某一特定用户(例如,用户 ​​Agil​​)在两个指定的日期之间的提交记录:

$ git log --oneline --since="2022-04-22" --until="2022-04-24" --author="Agil"

Git 有很多优点,其中一个优点就是 Git 让你能够收集你项目的相关数据。​​git log​​ 命令是一个重要的查看提交记录的工具,也是人们喜欢使用 Git 的原因之一!

责任编辑:庞桂玉 来源: Linux中国

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK