I have created a new project and checked the "create a local git repository" option. I opened the organizer to check that there is a repository for my project and it was there. I made some changes on some files, and noticed the source control specific letters "A" .. "M" beside them, but when I choose: File-> Source Control -> Commit, I get the following message from XCode 4.2:
the operation could not be performed because no valid working copies were found
Please verify that your files are under source control and try again
However, I opened the organizer again, and noticed that the repository of my project includes three icons on the left bar: Branches, Remotes and a folder with the same name as of the project. I chose the last one (the folder) and pressed the Commit button on the bottom bar of the organizer. The commit sheet opened and I performed the commit successfully. Now, when I close the organizer, and edit some files in my project, I do not see the source control specific letters "M" ... "A" ... beside each modified file.
My problem is about two points:
1) Why can't I commit from File->Source Control->Commit menu option
2) When I commit from the repository itself, and go back to the project and edit some files, why do not I see source control letters beside modified files?]
For what it's worth (and as #Jahelia's comment mentions), this seems to be a bug in XCode 4.2 when it first engages with git. The workaround seems to be to at least close Xcode and reopen. (If that doesn't work, try opening and closing the organizer.)
I encountered this myself today when trying out Git with Xcode for the first time. I created two demo projects with the "create a local git repository" option and they had the same problem. I was able to commit from the organizer window, but the main Xcode file view didn't seem to recognize git at all.
After quitting and restarting, I created a third demo with the git option, and the main window recognized the changes (after building) right off the bat - i.e showed the "M" beside a modified file.
I've experienced and recovered from this.
I can't tell you what causes it but, notably, in the "Repositories" view in my Organiser, I had TWO similarly-named repositories. What differed about them was the case of one of the paths.
One was "~/Work/Code/Bumhole" and the other "~/work/Code/Bumhole".
I caused the problem by XCode crashing during a commit to the repository (of many changes).
I fixed the problem by
closing the offending project
closing Xcode
rebooting
reopening Xcode
(close the project if its open)
open the Organiser view
Select the "bad" repository and delete it with backspace
Navigate the remaining "good" repository until you see the .xcodeproj file
Double click the .xcodeproj file to open the project
I expect this list is a superset of the steps needed to fix the problem, but this worked for me.
If your project is in /Developer/.... move it elsewhere and reopen the project. This may resolve your problem.
There seems to be a problem under Xcode 4.2 with projects in /Developer/... and git integration (you get the error "The operation could not be performed because no valid working copies were found. Please verify that your files are under source control and try again")
This bug still exists in Xcode 4.6.3 and when using Subversion.
I know this has already been answered but this worked for me:
Open terminal
cd yourprojectdirectory
git config --global user.email "youremail#email.com"
git config --global user.name "username"
Related
When I start a new project with GitHub I always struggle with the same issue. When I create a GitHub project it's already prepopulated with some files (.gitignore, LICENSE, README.md) and hence with an initial commit. I explicitly choose to add these items so I don't have to care about writing them myself.
On the other side, when I start a new Xcode project it works in a very similar way: Xcode creates an initial commit with some files. So when I'm trying to pull my GitHub repo I always have to deal with Git refusing to merge unrelated histories problem.
Is there a correct workflow for this?
Here is the easy way to do this, assuming that you are using a recent Xcode, e.g. 11.2...
create new repository in GitHub, checking .gitignore file and README.md file options
copy repository URL from browser's address field
create new project in Xcode, checking local git repository option
right click Remotes in project's source control navigator to add remote, using URL copied earlier, suffixed with .git
select Fetch and Refresh Status from Source Control menu
select Pull from Source Control menu, from origin/master remote (.gitignore and README.md files are now in your local repository... if in Finder, use Command Shift . to toggle hidden files display)
select Push from Source Control menu, to origin/master remote (Xcode project files are now in your GitHub repository)
Voila! You have set up a new project in Xcode and GitHub in less than a minute.
Just came across the same issue. It actually works on Xcode 11, if you follow these steps:
Create the repository on GitHub including initial branches, License, Readme.md etc.
At the Welcome screen of Xcode choose "Clone an existing project"
Clone your repository into the desired directory (usually a subdirectory of XCodeWorkspaces)
Close Xcode and reopen to get back to the Welcome Screen (that's the trick)
This time choose "Create a new Xcode project"
Place the project into the cloned directory. Xcode automatically picks up, that this directory is already under Git control.
You'll see that the initial files are marked with A and M in the Xcode project navigator
In the menu "Source Control" choose "Commit". You should see all files created by Xcode. Make sure to activate on "Push to remote:" and choose the right branch. Press Commit
If nobody committed or changed on GitHub between step 1 and step 7, it'll work. Check on GitHub.
So I went to sync my changes with Github and I ran into a few problems with main.storybaord. So I re opened Xcode, opened my project, and I saw a C next to my storyboard.
Now when I try to open it, nothing shows up except for an error message saying:
Interface Builder was unable to determine the type of
"Main.storyboard".
Please Help! Thanks!
The C means Merge Conflict.
You basically have two options:
revert to the last working revision
resolve the merge conflict by picking the correct change
The first one will revert all the changes that where made since the last commit. Right click the file, choose "Source Control" / "Discard Changes in ..."
The second one is best done from the terminal. Open the terminal, go to your project root and run
git mergetool
FileMerge will open, pick the correct changes in there.
Then do a
git commit
to commit the merge.
When trying to setup the source control feature in Xcode in an existing project, I changed branch to the one situated at github, but as I did that all my code disappeared an now I am not able to open the project as it says cannot be opened because it is missing its project.pbxproj file. Can I somehow switch back to my local master branch and recover my project? :(
For me, neither the issue or solution had anything to do with a source control repository. Somehow the project folder permissions got screwed up. To fix it, I opened the folder containing the project, did "Get Info..", clicked on the lock to unlock it, clicked on the gear icon near the bottom of the pane, and selected "Apply to enclosed items..." This reset the permissions throughout the project folder, after which I could open the project.
What has happened here is that you checked out a branch that does not contain the xcode project (or at least not all its components).
yes, you can switch back to the master branch and have everything that is in master including the project (assuming it was committed prior to master)
considering your problem you may need to use terminal to checkout master. in that case open terminal and cd to the project directory and do git checkout master
Here are the steps I take.
I open Xcode (4.3.3) organizer and select Checkout or Clone Repository
I choose the location https://MyUsername#bitbucket.org/MyUsername/myrepo.git
Press Clone button and it successfully clones it on my local disk
So I open the local copy of the project and perform some changes to it.
When I try to commit changes (or do any other git related operation) I get the following error:
The working copy "MyAppName" could not be reached.
Please verify that the working copy is reachable and try again.
However I can perform commits (and other types of git operations) without any issues from the Terminal app using command lines.
I've tried restarting my computer, deleting all Xcode settings, but nothing helped.
Update: I tried it again today and it works fine now. Maybe it's some sort of an intermittent bug in Xcode.
Whenever this happens to me (and it happens often) I do the following:
1-Close the project
2-Open the organiser
3-Go into the repositories tab.
If your current working copy has been added to the list already, then within the organizer navigate to it, and double-click on the .xcodeproj project.
This will re-open the project in XCode, and you'll find that now SCM operation will work fine.
If your current working copy hasn't been added to the list, press the + button in the bottom left corner, select "Add Working Copy", navigate to the folder containing the .xcodeproj and open this folder.
Now double click on the .xcodeproj file, the project will open in XCode.
And it's all working fine again...
No idea why this make things work... but it does
I have the same problem. It happens if you have ~/ in the path to project. Works fine, when you open your project from organizer.
It's a bug of Xcode! When you search the xxx.xcodeproj from your Home folder of the dialog box directly, Xcode will use the ~/xxx/xxx as the SVN/Git path which is completely wrong.
So you should avoid this, and search from the "/" path instead.
This is not exactly the answer you might be looking for, but I ran across similar problems when using Remote git repository (Github) and Xcode.
I ended up using a GUI tool "SourceTree", a good and easy to use tool to pull/push your code from Local Git to Remote Git Repository. Try it out http://sourcetreeapp.com/
This is an issue in XCode in which the built-in source control feature is unable to load the repository for projects located within a directory named with ALL-CAPS, such as ~/Documents/CODE. Running XCode 4.0.2 on a 2008 black macbook. If anyone has insight, please share.
This was the issue.
I create a new project, save it to the directory ~/Documents/CODE/...here-or-a-subdirectory-therein, making sure to check the "create local git repository" checkbox. I make a small edit to the AppDelegate or any other file, and Source Control commits will not work from within XCode. From the command-line, I see that .git was created in the project directory, and that the 'first commit' occurred. I can perform git commits from the command-line.
Possibly related issue: In Organizer->repositories, all my repositories have the yellow stoplight icon (even those I've gotten to work).
This was the Error:
When I try to commit from the project window (File-->SourceControl-->Commit, type a comment, and press commit) I get the following error:
The Working copy of "MyProjectName" failed to commit files.
fatal: '/Users/myUserName/Documents/CODE/MyProjectName/MyProjectName/MyProjectNameAppDelegate.m' is outside repository.
Over in the Organizer, I select MyProjectName (with the drop-down arrow and icon of the repository safe). The location is displayed as /Users/myUserName/Documents/CODE/MyProjectName/
But in the area where the commit comments are normally displayed, I see the message:
Unable to load revisions.
The likely cause was that XCode was internally identifying the Project directory as ~/Documents/Code, not ~/Documents/CODE.
One way to resolve the issue was to rename ~/Documents/CODE to ~/Documents/Code, then in Organizer (select the Repositories Tab) I deleted the repository listing for MyProjectName.
NOTE - Only removes XCode's reference to the repository, the actual repository remains intact. Now Close XCode and Reopen it. Open the project MyProjectName. XCode will recreate a reference to the Project with the correct Capitalization. Note that the renaming of the directory seems to force XCode to recognize the new directory name when the repository is recreated.
Another way to resolve the issue is: within XCode's Organizer window (select the Repositories Tab), delete the reference to the repository. Then, still in Organizer, select the "Projects" tab at top. To the left of the project's window is a list of all the projects...select MyProjectName. Now in the center frame is a field named "Derived Data" with a path to your project. Click the little -> arrow to the right of the PATH to open up the Project's Internal Settings Directory in Finder. Open the file called "info.plist" and edit the key "WorkspacePath" such that it's value EXACTLY MATCHES the location of your project (correct the capitalization of the directory if necessary). Save, and return to Organizer. Close XCode. Reopen XCode and the repository reference will be recreated. You can go directly into Organizer now, select the "Repositories" tab, then select MyProjectName's repository. You'll see the commit messages there (even if you haven't committed yet, you'll still see the auto-generated 'first-commit' that occurred internally when your project was created).
I just ran into this problem. Luckily, restarting Xcode did the trick for me.
You should probably consider using i case sensitive HFS Volume for your source files.
This way you avoid name clashes like the ones you see.
You could try and create a disk image using a case sensitive filesystem and see if your problem persists.
I had similar problem and the problem in hidden .git folder.
I added external class which I cloned from git repository and when I was adding files to my XCode project I accidentally added hidden .git files.
When I removed them everything started working correctly.
I had the same issue. You must to remove this problem file from project (only reference) and then return it back.
Happened to me that the little checkboxes next to the files in the commit window were all deselected. I selected them and this error came out.
Restarted XCode and it was the same but I noticed that the Commit button was enabled although the files were still deselect.
Tried it and it was successful...
Sometimes XCode is so strange