For all commits where you want to change the date, replace pick by edit (or just e ), then save and quit your editor. The first date is the commit date, the second one is the author date. Repeat the process until you amend all your commits. Check your progression with git status .
The author is the person who originally wrote the code. The committer, on the other hand, is assumed to be the person who committed the code on behalf of the original author. This is important in Git because Git allows you to rewrite history, or apply patches on behalf of another person.
When you run git log , by default you will see the author date. If you want to see commit date, you can use one of the many command line options, such as --pretty=fuller . Note the (slight) difference between the author date and commit date above. The author date is my original, unedited, commit time.
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 (more).
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
The author date on a commit is preserved on rebase / cherry-pick etc. But the commit date is changed.
I happened to be in a situation where github showed different commit times from git log
and I thought this was a bug with Github.
Turns out github shows the CommitDate
and git log
shows the AuthorDate
(without the fuller
flag).
This happened because I cherry-picked two commits from a different branch. While cherry picking the commit timestamps change just like when doing commit --append
.
Git rebase
retained the commit date in my case.
Also to check the AuthorDate and the CommitDate in git log use --format=fuller
Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With