27

Xcode is showing multiple working copies:

Working Copies
myProject - master
myProject_olderRepo
myProject_originalRepo

The second two are greyed out.

The original code was cloned in Sourcetree from the repo of a previous owner. Not knowing how to move the files into a new repo, I simply copied locally the entire project directory, and started work on them. Then I copied the contents of that reworked project directory into a folder linked to a repo to which others have access. When they clone the repo they get compile errors because modules (the two older repos) are missing.

I have almost no experience of source control and Bitbucket et al, so I humbly ask forgiveness for anything completely stupid that I am doing.

How do I remove those older working copies from Xcode's source control? Or is there some other way that others can then clone and compile the project without errors?

HenryRootTwo
  • 2,572
  • 1
  • 27
  • 27

12 Answers12

45

Solved this by deleting xccheckout file under

ProjectName.xcodeproj > project.xcworkspace > xcshareddata

This had contained references to the previous repos.

erkanyildiz
  • 13,044
  • 6
  • 50
  • 73
HenryRootTwo
  • 2,572
  • 1
  • 27
  • 27
23

I have removed old repo using following steps.

  • ProjectName.xcodeproj -> Show Package Contents
  • project.xcworkspace -> Show Package Contents
  • xcshareddata
  • Open .xcscmblueprint file using any text editor
  • Remove all unrequited repo from following location DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey
  • Save file and open Xcode again

Note : If your project have WorkSpace then Direct click on ProjectName.xcworkspace instead of ProjectName.xcodeproj

Piyush
  • 1,156
  • 12
  • 20
10

I am using Cocoapods and have a .xcworkspace along with my .xcodeproj.

This is what worked for me:

  1. Remove Cocoapods from the project using pod deintegrate in Terminal.
  2. Run pod clean
  3. Run pod install to create it again.

Now if you open the Workspace again, the other Working Copies should no longer exist.

O-mkar
  • 5,430
  • 8
  • 37
  • 61
Alain Stulz
  • 715
  • 6
  • 19
  • Thank you. I had tried all the other approaches first and they didn't work. I guess using Cocoapods changes things. – avance Feb 14 '17 at 22:12
4

This solution helped me. Go to terminal and paste below code (this will show hidden files)

defaults write com.apple.finder AppleShowAllFiles YES.

Now go to your project folder and check if there is any .git files outside your working project folder. enter image description here

.git file that is located outside project folder do not belong to your working project but other project. ( This is possible if you have made mistake in creating git for other project)

Either cut paste this .git file and save it some other location or you can delete it (if not so important). After deleting , reopen your project in xcode.

cgeek
  • 558
  • 5
  • 18
  • 2
    Two things. One, if you use that in terminal, you have to restart Finder for the changes to take effect. But more importantly, while in finder, simply press COMMAND-SHIFT-PERIOD to toggle hidden files on and off. No terminal needed. Enjoy! :) – Mark A. Donohoe Feb 15 '18 at 16:02
  • 1
    Aha.. Thank you for the info :) – cgeek Feb 16 '18 at 04:44
2

If you have Git repositories showing up, then you must have a *.xcscmblueprint file somewhere in your project. For me, it was in my workspace and not in a project. From terminal window:

% find . -name '*.xcscmblueprint' ./TaskMe.xcworkspace/xcshareddata/TaskMe.xcscmblueprint

Edit that file with care to keep just the entry you want. Or perhaps better, just delete the file and add back the repository you want.

Brad Howes
  • 114
  • 1
  • 6
  • 1
    Deleting was the best option for me after messing around (for too long! lol) wi the xcscmblueprint file – dustinrwh Mar 31 '17 at 23:48
1

If this issue happens when using CocoaPods try:

  • Remove myProject.xcworkspace
  • Remove Pods/
  • Run pod install
vicegax
  • 4,709
  • 28
  • 37
1

Project.xcodeproj -> Show Package Contents

Project.xcworkspace -> Show Package Contents

xcshareddata

Open .xcscmblueprint file

Clean all content

Save file and open Xcode again

virgiltang
  • 36
  • 2
1

You might have used other project files. (it happens when you drag files to XCode and you forget to checkmark 'copy items if needed').

checkout: Xcode git showing multiple repositories

Amirca
  • 143
  • 1
  • 8
0

Not sure what happened here, I had one project but two working copies, similar to question. One of the working copies was synced with a repo on GitHub, and I had successfully pushed changes there. All I had to do, in the end, was to delete my local folder completely, then check out (clone?) from the remote repo on github again.

(I'm not sure but I got the feeling that Xcode and/or the Xcode project was NOT handling multiple working copies, but that this was done like a top layer in the git structure itself. Maybe it is a feature of git?)

Jonny
  • 15,955
  • 18
  • 111
  • 232
0

I had two instances of the same project in my ProjectNavigator in XCode. One of them was marked with M and the other one with ?

All I had to do to get rid of the copy, was delete the project marked with ? by control-clicking on it and selecting delete.

DevB2F
  • 4,674
  • 4
  • 36
  • 60
0

Follow the following steps:

1.  Open terminal and go to your project directory
2.  Run pod deintegrate in Terminal to remove Cocoapods from the project.
3.  Run pod clean
4.  Run pod install to create it again.

Open .xcworkspace, worked for me.

Devendra Singh
  • 717
  • 1
  • 13
  • 14
0

I had forked a project and the new fork was still pointing to the original project files, so I was seeing Git for both the new and the original project. To fix I did the following:

Project.xcworkspace -> Show Package Contents
contents.xcworkspacedata -> Change Path
Neil Faulkner
  • 526
  • 1
  • 4
  • 22