Duncan C
Duncan C

Reputation: 131491

How do I remove a second remote git repo from an Xcode project?

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.

Upvotes: 12

Views: 4847

Answers (5)

F.A. Botic
F.A. Botic

Reputation: 111

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.

Upvotes: 1

Bruce Cichowlas
Bruce Cichowlas

Reputation: 336

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?

Upvotes: 1

Badr Bujbara
Badr Bujbara

Reputation: 8691

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

enter image description here

There you can add/delete remotes

Upvotes: 1

Alexander Telegin
Alexander Telegin

Reputation: 714

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!

Upvotes: 29

matt
matt

Reputation: 535925

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.

Upvotes: 7

Related Questions