8

This problem happens all the time and it drives me crazy. I will add, commit and push a file up to github and it will display the wrong time as to when it was committed. Sometimes it will show that the commit happened a few days prior to when it actually was just added, committed and pushed (which rules out a simple timezone discrepancy). Even when I initialize a brand new repository and commit a file immediately afterward, it will say that it happened 2 days ago.

If anyone knows of an article or previously answered question that deals with this issue, I would greatly appreciate you pointing it out to me.

Noam
  • 587
  • 5
  • 11

3 Answers3

5

Double-check your system clock. GitHub's UI is showing the timestamp from the commits themselves, which git reads from the system when you make the commit.

A quick way to check this is to make a new commit, then do git log and check that the time and date match the settings on your system.

Ben Straub
  • 5,675
  • 3
  • 28
  • 43
  • You're right. It appears that it's my VM that's messed up. How can I fix it? – Noam Nov 19 '13 at 21:39
  • Manually? Depends on the OS. Your VM hosting software might have a setting for this, though: http://stackoverflow.com/questions/276965/how-to-keep-a-vmware-vms-clock-in-sync – Ben Straub Nov 20 '13 at 13:38
2

I encountered the same issue while using WSL, these two commands fixed it for me.

First ensure ntpdate is installed:

sudo apt install ntpdate

Then run:

sudo ntpdate pool.ntp.org

You can read related questions/threads on this issue here and here.

Rohan Nero
  • 131
  • 5
1

This is how I reset the time on my scenario to fix this issue.

I use Ubuntu on WSL. I'm not sure why my time was off, but I shut down WSL, and ubuntu restarted(when I opened it) with the correct time from PC's system time.

Use the following command in Windows PowerShell to shut down WSL :

wsl --shutdown

After restarting Ubuntu use this command in Ubuntu to check the time:

date