gpt4 book ai didi

git - 为什么 git AuthorDate 与 CommitDate 不同?

转载 作者:IT王子 更新时间:2023-10-29 00:32:10 28 4
gpt4 key购买 nike

我查看了我的 git 日志,发现我的一些提交的 AuthorDate 和 CommitDate 略有不同。从 git log --pretty=fuller 输出:

commit 3a5912f90dc5227f308e99f95152fbee2301c59a
Author: <hidden>
AuthorDate: Fri Jun 15 10:57:22 2012 +0800
Commit: <hidden>
CommitDate: Fri Jun 15 11:14:37 2012 +0800

Author 和 Commit 是同一个(我)。

这是怎么发生的?我困惑了好几天。

还有更多 - 它发生在 341 次提交中的 17 次:

+------------------------------+-------------------------------+
| from_unixtime(authored_date) | from_unixtime(committed_date) |
+------------------------------+-------------------------------+
| 2012-06-15 10:57:22 | 2012-06-15 11:14:37 |
| 2012-06-15 14:39:54 | 2012-06-15 14:48:57 |
| 2012-06-19 12:28:21 | 2012-06-19 12:29:41 |
| 2012-06-21 18:16:25 | 2012-06-21 18:28:48 |
| 2012-06-26 17:30:54 | 2012-06-26 17:33:55 |
| 2012-07-13 11:41:43 | 2012-07-13 11:42:17 |
| 2012-07-13 11:56:02 | 2012-07-13 12:13:22 |
| 2012-07-13 12:05:09 | 2012-07-13 12:12:24 |
| 2012-07-12 18:38:49 | 2012-07-13 12:26:35 |
| 2012-07-13 11:00:47 | 2012-07-13 12:25:15 |
| 2012-07-16 14:10:54 | 2012-07-16 14:15:01 |
| 2012-07-13 12:56:51 | 2012-07-16 13:49:48 |
| 2012-07-16 14:10:54 | 2012-07-16 14:19:46 |
| 2012-07-24 16:05:05 | 2012-07-24 16:05:48 |
| 2012-07-24 17:42:58 | 2012-07-24 17:43:33 |
| 2012-07-24 17:42:58 | 2012-07-24 17:45:18 |
| 2012-07-26 16:55:40 | 2012-07-26 16:55:53 |
+------------------------------+-------------------------------+

最佳答案

author date 记录了最初提交的时间(即完成 git commit 的时间)。根据 git commit 的文档,可以使用 --date 开关覆盖作者日期。

每次修改提交时,提交日期都会更改,例如,将提交所在的分支 rebase 到另一个分支 (more) 时。

如果您进行提交并将补丁发送给另一个人以便在另一个仓库中应用该补丁,则可能会发生同样的情况:作者日期将是您的 git commit 的日期,即提交日期将设置为在其他存储库中应用补丁时的那个日期。

如果您将补丁发送给两位同事,将有一个作者日期和两个不同的提交日期。

Git Book 中也提到了这一点:

You may be wondering what the difference is between author and committer. The author is the person who originally wrote the patch, whereas the committer is the person who last applied the patch. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer

关于git - 为什么 git AuthorDate 与 CommitDate 不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11856983/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com