Search code examples
gitgithubgithub-for-mac

After Installing Github for Mac Existing Project Reverted to Version About a Month Old


I recently installed Github for Mac. During the setup process I imported an existing Xcode project, which was open at the time. Upon doing that Xcode prompted an alert saying that the project had changed and asking if I wanted to re-save. I opted to resave because I thought the changes it was referring to was the fact that I had just added the project to git. I didn't think that the actual code files were changed in the process. Unfortunately what really happend is that the project reverted back to a version from late March, costing me about a month and a half of work.

Does anyone have any suggestions about how I can undo the damage I just caused? I can't figure out why it chose a date in March to revert to. Perhaps that was the last time I committed the code using Xcode's source control. There's a version in Time Machine that I can use to restore the project, but that is at least a couple of weeks old. Before doing that I was wondering if there's a better solution.


Solution

  • Check what git log shows. It will list all commits. If you have a commit, you can restore the source code to that point. (You could do this by, for instance git reset --hard <committish>)

    (If you have done something really strange, you can also check git reflog for commits no longer shown by git log, but that does not seem likely.)

    Unfortunately it sounds like you last committed in March. In that case Time Machine seems like the best option.