Search code examples
gittimemachine

git is out of date after a Time Machine restore


I just reverted my Mac back to its state 10 days ago using Time Machine. I then updated my website's repository folder back to 1 day ago to keep coding.

When I run git status or gitk, it shows the 10-day old view, not the current view, so it's missing some recent commits. Where is the folder/file I have to update to get the current data?

In case this clarification is needed, my origin on Github has commits from 6/10, 6/7, 6/1, and 5/30. My faulty git status only shows commits 6/1 and 5/30, and the other files are just floating around in the staging area as if never committed.


Solution

  • Problem's cause

    My local folder contains a hidden .git folder, which is the local repository (thanks @JonathanLeffer). Time Machine did not restore the .git folder when I selected all files in my repository for a manual restore.

    Solution

    I manually restored .git to its state as of 1 day ago, making sure to choose 'replace' for all files to make sure the old files are overwritten with the newer ones. After running gitk, all commits are visible for 6/10, 6/7, 6/1, and 5/30.