10

I'm working on multiple projects in xcode all are hosted on GIT with each having separte repository and multiple braches. In one of my project it is showing multiple repository. This case occurs while taking pull/push/discard changes.

enter image description here

This is the case. I need to uncheck the other one to pull/push/discard in current project. I've tried checking out new project too. But no success. How can I remove the other project here?

PS: It's only occurring in one of my project while others are working fine.

HangarRash
  • 7,314
  • 5
  • 5
  • 32
Rohitax Rajguru
  • 893
  • 2
  • 13
  • 35

5 Answers5

19

I got stuck into the same issue while working on multiple projects in Xcode. This happens when we add files from another project and therefore the Xcode starts showing repository of other project also. The files are not exactly copied in the new project but only reference is added.

To fix this issue lets assume you have added files from project named "Project-old" to project named "Project-new". And Project-new is showing multiple repositories. Now, do the following steps:

  1. First you need to identify files which are added from Project-old. Easiest way is to rename the Project-old folder temporarily to "Project-old-check". Now open Project-new. you will see the red highlighted files in Xcode project navigator.
  2. Select the highlighted file and update the path of file from File inspector. You may need to copy this file from Project-old to Project-new manually with Finder.
  3. Repeat this process for all other red highlighted files and close Xcode.
  4. Relaunch Xcode and Open project by double clicking .xcodeproj or .xcworkspace file. Do not open project from Xcode welcome screen or recent files.
  5. Try pushing now. you will see only one repository now.

You can rename "Project-old-check" back to "Project-old" now.

Hopefully this will help someone.

DZoki019
  • 382
  • 2
  • 13
Nabeel
  • 841
  • 1
  • 10
  • 23
  • for my more complicated case: `Project-New` added reference file, but have deleted, still same error. in the end, for `Project-New` and renamed `Project-old`, both do **Clean Build Folder**, then issue solved. – crifan Mar 03 '22 at 06:37
  • append: finally, rename `Project-New` -> `Project-New_bak`, XCode clean, and rename back `Project-New_bak` -> `Project-New` , XCode clean, really worked !!! – crifan Mar 03 '22 at 07:12
  • This fixed my problem as well. After identifying the files from step #1, I quit Xcode, and using Finder, copied the files over. Restarted xcode and the extra repository no longer showed up under Source Control > Push – Benson Wong Nov 18 '22 at 19:01
1

Try to delete "derived data" folder for fixing the issue.

Note: You can reach to derived data folder by using the path;

Xcode -> Preferences -> Locations

emresancaktar
  • 1,507
  • 17
  • 25
0

If I understood your question correctly, then this is a case where you have multiple remotes configured to the project in question. To verify, you can open command prompt and go to your project directory.

Type git remote -v. This will give you list of all remotes. You can delete the remote location you don't want with git remote rm destinationUrl. To learn more about detatching remotes, click here.

Once you remove the extra remote, you'll see only one option in your xCode window. In case if you are wondering what is remote, then this may help you.

Krantisinh
  • 1,579
  • 13
  • 16
  • 3
    I have same problem but "git remote -v" only shows the one, correct repository. The Source Control navigator shows two repositories, with the unwanted one even listing some recent commits I made which I never actually sent to this incorrect target because I unchecked this target before pushing (and fortunately neither are these commits are actually in that remote either). What a mess! – gpdawson Nov 04 '19 at 06:23
  • Hi @krantisinh, thanks for your answer, but this problem is not because of multiple remotes. It's more Xcode specific. – James Selvakumar Jun 30 '21 at 04:27
0

You can see the location of each repo if you select it in the source control window and look at the file path in the inspector.

This helped me realize I had a duplicate of my project in an iCloud archive folder. The archive folder was created because I signed out of iCloud, and macOS made a copy in my home directory titled "iCloud Drive (Archive)". I then later signed back into iCloud. Xcode was showing me BOTH repos, even though I was only using the current Xcode project.

The solution was to make sure my latest changes were copied to the current one and to delete the archive folder.

Sidenote: If Xcode would just look at whatever .git folder is in the project file instead of trying to be clever and link repos to files it would've saved me an hour.

inorganik
  • 24,255
  • 17
  • 90
  • 114
0

The problem of multiple xcode repositories could also be if you are using cocoapods in your project, and are at the same time cloning projects into new separate entities. So if indeed you are using cocoapods i suggest to check the answer I've posted here cocoa pods project cloning and the problem with multiple xcode repositories

F.A. Botic
  • 71
  • 1
  • 2