Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4.0.2 Git Commit Error: fatal: '...' is outside repository (Possible Bug)

Tags:

git

xcode

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).

like image 638
ObjectiveTC Avatar asked Jun 16 '11 19:06

ObjectiveTC


1 Answers

I just ran into this problem. Luckily, restarting Xcode did the trick for me.

like image 62
Chris Avatar answered Nov 15 '22 03:11

Chris