10

In working on a large client project, I added a couple of source files from one of my company's other projects (Debugging utilities.) Both projects are connected to remote repos.

I must have either dragged the file from the project window instead of the finder, or failed to click "copy files (if needed) in the add resulting dialog.

In any case, when I now go t push or pull, it lists both repos in the list of remote repos connected to the project.

I don't want my client's project tied to my company's other repository. I want all the files in the project to come from the client's repo.

I tried removing the source files that I added and then re-adding them with the "copy files" checkbox checked, but it still lists the other remote repo.

How do I get rid of the second, unwanted git repo from the project?

EDIT:

Note that the project is actually contained in an Xcode workspace. I just found a mention of the unwanted repo in my workspace's .xcworkspace/xcshareddata/.xcscmblueprint file.

Community
  • 1
  • 1
Duncan C
  • 128,072
  • 22
  • 173
  • 272

5 Answers5

26

So since the correct answer was never added here I'll do it myself: you have to delete the Xcode's Derived Data for it to forget about the link once you remove the references to other git repo's source files in the projects.

The easiest way to do so is to go to Xcode -> Preferences enter the Locations tab and press the little arrow beside Derived Data location (in the red box):

enter image description here

Just delete the entire folder (it's good to do so every once in a while to free up the space) and you are good to go!

Alexander Telegin
  • 665
  • 1
  • 7
  • 22
6

Try in the Terminal:

$ cd /my/project/folder
$ git remote

Now you know the names of the remotes.

$ git remote remove myUnwantedRemote

Of course all this is easy without Terminal if you use SourceTree.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Also you might want to delete the unwanted repo from Xcode's Accounts pref pane. – matt Apr 01 '16 at 18:29
  • 3
    Matt, thanks for the quick reply. The command `git remote` just yields "origin". The other repository is not unwanted. It's for a project that belongs to my company, not the client. I want it to still be available in Xcode, just not attached to the client project. (See the edit to my question.) – Duncan C Apr 01 '16 at 18:34
  • Try `git remove --verbose` to get more info, perhaps. – matt Apr 01 '16 at 18:38
  • `git remote --verbose`, or `git remove --verbose`? – Duncan C Apr 01 '16 at 18:39
  • I already tried `git remote -v`. It just shows the full path to the remote, twice (once for fetching, once for pushing.) – Duncan C Apr 01 '16 at 18:40
  • "I just found a mention of the unwanted repo in my workspace's .xcworkspace/xcshareddata file." Brilliant! You could try to edit by hand. Otherwise, here's my suggestion: when you push/pull, use SourceTree (or the Terminal), not Xcode. We'll probably never figure out where Xcode is getting its ideas about this. Let's fact it, Xcode source control support just sucks. I have it turned off, personally. – matt Apr 01 '16 at 18:43
  • "Let's fact it, Xcode source control support just sucks." True that. One of the developers at a client site used SourceTree, and it seemed to suck as well, and from the little i saw of it, seemed to suck even more than Xcode. You like it? (I end up dropping into terminal for the stuff that Xcode can't do.) – Duncan C Apr 01 '16 at 19:46
  • Very much. I am a long-time git command line person and I think SourceTree rocks. – matt Apr 01 '16 at 19:56
  • Since posting this question I've started using a paid app called "Tower" which seems quite a bit better than SourceTree. I still need to drop to command line from time to time, but it's a whole lot better than Xcode's abysmal support for source control. – Duncan C Dec 12 '16 at 21:06
1

In Xcode, there is a Source Control navigator next to the Project navigator:

enter image description here

There you can add/delete remotes

fullmoon
  • 8,030
  • 5
  • 43
  • 58
1

As described in an answer above, the only thing I got out of doing "git remote" was origin, despite the two repositories showing in xcode. The solutions above did not work for me. I could see that the problem existed with the repository tab at the left, but I couldn't figure out what to do from there.

What did work was temporarily renaming the directory of the project from which I had copied files. If files names turn to red, you are already seeing the files involved. In my case, I didn't see these but when I did a clean and rebuild my project, it has a problem with xcassets. And, indeed, I had "copied" the xcassets from a similar project, but somehow was linked to the same file. After deleting the xcassets red entry, I then did an "import" from the "Resource Tags" tab of the project and checked that I did now have an xcassets file that was in my project.

My description may sound complicated, but the whole process is better described in the answer from Nabeel here: How do I remove a second remote git repo from an Xcode project?

Bruce Cichowlas
  • 336
  • 1
  • 7
1

The above solutions did not help my case but I found a different solution for my prob.

The problem of multiple xcode repositories could also be if you are using cocoapods in your project.

For example you had an old project named project_1. You successfully cloned that project to a new project named project_2 and pushed all the data to a new git repository.

Now in xcode on the Repositories tab of the new project_2 and the old project_1 suddenly you have both the old and the new repository visible.

The problem is then most likely related to Pods references which still remain from the old project. Xcode thus loads both repositories as certain pods files still reference the old project.

If that is the case i suggest to do the following:

  • Push all changes from project_1 and project_2 to their git repository
  • Delete all directories containing project_1 and project_2 and chekout (clone) the projects again. If in this case you still see multiple repository then do the following:
  • run commands "pod deintegrate" and then "pod cache clean --all" in both project directories
  • now run command pod install in both project_1 and project_2 directories

Hopefully now you should not have any more references between the two projects and on the "Repositories" tab you should only see one repo.

F.A. Botic
  • 71
  • 1
  • 2