为什么git AuthorDate与CommitDate不同? [英] Why git AuthorDate is different from CommitDate?

查看:1449
本文介绍了为什么git AuthorDate与CommitDate不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  commit 3a5912f90dc5227f308e99f95152fbee2301c59a 

我查找了我的git日志,发现AuthorDate和CommitDate在我的一些提交中略有不同:
作者:< hidden>
作者日期:星期五6月15日10:57:22 2012 +0800
提交:< hidden>
CommitDate:Fri Jun 15 11:14:37 2012 +0800

作者和提交是一样的我。



这是怎么发生的?



还有更多(发生在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 开关重写作者日期。



每次提交被修改时,提交日期都会发生变化,例如,当重新绑定提交所在的分支时,另一个分支上。

如果您进行提交并将补丁发送到另一个补丁以将补丁应用到另一个补丁中,则会发生同样的情况:作者日期将是您的 git commit

作者日期,但有两个不同的提交日期。



这也在 Git Book


您可能想知道w不同之处在于 author committer 之间。 作者是最初编写补丁的人,而提交者是上次应用补丁的人。因此,如果您向项目发送补丁并且其中一位核心成员应用此补丁,则您都会获得信用 - mdash;你作为作者和核心成员作为提交者



I lookup my git logs and find that the AuthorDate and CommitDate is slightly different for some of my commits:

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

The Author and Commit is the same me.

How does this happen? I am puzzled for days.

There are more(happens in 17 out of 341 commits):

+------------------------------+-------------------------------+
| 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           |
+------------------------------+-------------------------------+

解决方案

The author date notes when this commit was originally made (i.e. when you finished the git commit). According to the docs of git commit, the author date could be overridden using the --date switch.

The commit date gets changed every time the commit is being modified, for example when rebasing the branch where the commit is in on another branch.

Same could happen if you make your commit and send your patch to another one in order to apply the patch in another repo: the author date will be the date of your git commit, the commit date will be set to that date when the patch is applied in the other repo.

If you send the patch to two colleagues, there will be one author date but two different commit dates.

This is also mentioned in the 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 AuthorDate与CommitDate不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆