Barney Szabolcs
Barney Szabolcs

Reputation: 12514

How to restore version control in XCode?

I have just recently backed-up my XCode C++ project on my pendrive, using

rsync -avu 

Since then, the version control for my project is grayed-out on every files, I can modify the files and not see the "M" nor the "A" sign. The only files still having version-control working "shared" files for which it works correctly. (Those shared files belong to a different project called "Shared").

I have tried git commit -m, git add . and even git init where the files were. Nothing worked.

Can you please help restoring version control for my project?


UPDATE:

Answers for the questions in commens (and answers):

  1. my git repository is on my local hard drive.
  2. I went to the Organiser-repository pane in XCode and I see my recent git commit -m "sth" as "sth" az a commit. I have a single branch: master.
  3. Im not sure what command would be good to test git, as my commits work (theoretically).
  4. I have a folder named .git in the project folder.
  5. git log is working, showing the same as XCode Organiser-repository pane.

I think the XCode just can't synchronise with the git for some reason, and I don't know how to correct that.

Upvotes: 1

Views: 262

Answers (1)

herzbube
herzbube

Reputation: 13378

First off, this is not an answer that will fix your problem, I just try to provide some help that might get you closer to a diagnosis.

Git stores its files in a folder named .git. Check if this folder is present in your project. If it's not then your Git repository is gone.

Next, try some basic command such as git log. For this to work, you must first cd to your project folder (or a subfolder thereof), because whenever you run a Git command it will look for the .git folder in the cwd or a parent folder. If git log does not work then your Git repository is broken in some way. Someone else will have to step in to further diagnose the problem, as I am no expert on this subject.

Finally, you should also check whether your rsync command has really sync'ed your project's .git folder with the backup's .git folder. Use this command:

diff -rq /path/to/project/.git /path/to/backup/.git

If there is no difference (as I would expect if rsync has worked correctly) then the problem with your Git repository is both in your project and in your backup. If there are differences then it might be worthwile to try your next steps on a copy of the backup (it should be fine to make the copy in the Finder).

Good luck.

Upvotes: 1

Related Questions