My commit time differs between origin and local. The time in local is right. I have tried git push -f
but that does not work. I believe that it is related to the git rebase but I don't know how to fix it.Is there a way to make my commit time in origin the same as my local commit time?

- 135
- 8
-
This isn't an issue Git can resolve. You need to ensure that the system clocks on the relevant machines are accurate. – chepner Jan 19 '23 at 15:50
-
1But see https://stackoverflow.com/q/11856983/1126841 – chepner Jan 19 '23 at 15:54
-
@chepner, thanks for your answer, but system clock works well and I believe that github remote works too. – SNORLAX Jan 19 '23 at 15:55
-
1See the above link. I suspect the problem is not that the times are out of sync, but that you are looking at two different timestamps on the same commit. – chepner Jan 19 '23 at 15:57
-
Thanks for your link, my laptop isn't at hand so I will check later. – SNORLAX Jan 19 '23 at 15:58
-
1What's the output from `git show 3f2af8f`? Commits have two timestamps, an **author** timestamp and a **commit** timestamp. If you `commit --amend` or `rebase` they can differ. Commit times *also* include your time **zone**. Perhaps the web site is converting time zone. – amphetamachine Jan 19 '23 at 22:04
-
@chepner You are right! The author time differs from commit time! Thank you! – SNORLAX Jan 30 '23 at 15:20
-
@amphetamachine Also thanks for your answer! The link above is the key. – SNORLAX Jan 30 '23 at 15:21
1 Answers
Try inspecting the output from git show 3f2af8f
or git cat-file -p 3f2af8f
.
Commit times also include your time zone. If the system time zone is not set correctly on your computer, they may be hours off. Perhaps the web site you're viewing the commit details under is converting the time zone.
More on commit time stamps
Commits have two timestamps, an author timestamp and a commit timestamp. If you commit --amend
or rebase
they can differ.
If you inspect the commit directly using git cat-file -p <commit>
, you can see the timestamps in UNIX Epoch seconds.
I had to commit --amend
this commit, so the times are different. I've underlined the timestamp in red, and the time zone in blue:
You can actually specify the timestamps git uses when adding commits using some operations. commit --amend --date=now
or --date='2023-01-13 13:13:13'
or rebase --committer-date-is-author-date
to name a few tricks.

- 27,620
- 12
- 60
- 72