8

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
  • 122,346
  • 22
  • 162
  • 258

4 Answers4

19

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
  • 572
  • 1
  • 5
  • 22
5

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
  • 485,702
  • 82
  • 818
  • 1,064
  • Also you might want to delete the unwanted repo from Xcode's Accounts pref pane. – matt Apr 01 '16 at 18:29
  • 1
    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
  • 7,409
  • 4
  • 39
  • 57
0

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?