Why is the date of commits in git log out of order?

前端 未结 2 1060
[愿得一人]
[愿得一人] 2021-02-07 12:38

When I do a \'git log\', why is the date of the commits out of order?

I am looking at 1 branch of my repository. the date should be in order, right?

2条回答
  •  既然无缘
    2021-02-07 13:04

    No, not necessarily.

    Git tracks two dates. The author date says when the original author made the commit. In the case of email patches it might be taken from an email date. The patch might be applied at a much later time.

    The commit date is often in order as that says when a commit is made, and a commit can only be made when its parent exists. If a commit is rebased or cherry-picked it will be given a new commit date but the original author date will be preserved. However, even the commit date is taken from the local system time of the machine where it is made so it is subject to whatever the local clock happened to be set to. In general there's no guarantee that this will be accurate or consistent across machines.

    (Both dates include timezone information.)

提交回复
热议问题