Xcode 9.2 hangs on commit to GIT

I have an app that uses a local git repository. Until today I've had no trouble with git functionality. Today, trying to commit the project, Xcode hangs with the spinning beach ball as soon as the commit window appears. If I try to commit an individual file, it appears to start the commit (that is, it takes a comment), but hangs with a message "Committing..." in the lower-right hand corner.


My git expertise is limited to using it within Xcode and some basics from the command line. I'd appreciate any insights and advice on how to get it working in Xcode again.


Thanks,

John

Accepted Reply

Perhaps the next thing to check is that the source files are in the expected places.


Also, I'm assuming you have cleaned the build folder, closed the project and re-launched Xcode. If Xcode crashed in the middle of a commit previously, I could believe it might be confused about the state, but those steps ought to resolve that.


Another thing to try is to use Terminal to move the .git folder elsewhere (or, easier, rename it to something else without moving it to a different directory). Again, you'd do that with the project closed. After that, open the project and verify that Xcode thinks it's not under SCM. Them, put the .git folder back, and see what Xcode thinks after you re-open the project yet again. If that's still messed up, I'd guess that the .git directory contents are somehow corrupt.


You could also take a look at the repository using an app like SourceTree, and see if it is confused like Xcode.

Replies

It's worth taking a look at a 'git status' from the command line, and see whether it just contains files ready to commit, or whether there are other things going on. If nothing looks messed up, you can try committing from the command line (git commit -M "<commit message>") — but quit Xcode before you do that.


Before you try to fix the problem, I suggest you submit your project (if you can) with a bug report.

Thanks, Quincey. git status showed no uncommited files, which is odd because Xcode shows lots of files with an M, indicating they not committed. Doing a commit did nothing because outside of Xcode, git sees nothing to commit. I made a copy of the project (which I'll try to send with a bug report), then did a git init. Nothing changed, inside or outside of Xcode.


I'm wondering if Xcode is using a respository outside the app's root directory. A .git folder appears there, but after the git init, Xcode still shows branches; I thought the init would esentially clean out the repository and do an initial commit of the app. Is there a way to see where the git repository is?

If there was already a .git folder there, I wouldn't be certain a git init did anything.


You can see where Xcode thinks the repository is by looking at the Source Control navigator (Command-2) and choosing the Source Control inspector (Command-Option-3). The path to the working copy is there.

Thanks, again for your response; I appreciate your help. I fgured out how to look for the correct repository and it is, in fact, in the app's root directory. So I'm baffled: from the command line, a git status shows nothing to commit, a git branch shows no branches, but Xcode shows files to commit and several branches I've created. Somehow, Xcode has gotten out of sync with the repository. That may not be the problem that's causing the hang, but it sure makes me suspicious. Doing a Fetch and Refresh Status from the Xcode Source Control menu has no effect.

Perhaps the next thing to check is that the source files are in the expected places.


Also, I'm assuming you have cleaned the build folder, closed the project and re-launched Xcode. If Xcode crashed in the middle of a commit previously, I could believe it might be confused about the state, but those steps ought to resolve that.


Another thing to try is to use Terminal to move the .git folder elsewhere (or, easier, rename it to something else without moving it to a different directory). Again, you'd do that with the project closed. After that, open the project and verify that Xcode thinks it's not under SCM. Them, put the .git folder back, and see what Xcode thinks after you re-open the project yet again. If that's still messed up, I'd guess that the .git directory contents are somehow corrupt.


You could also take a look at the repository using an app like SourceTree, and see if it is confused like Xcode.

>Xcode 9.2 hangs on commit to GIT


Might want to move to Xcode 9.3 - it's release notes mention 3 'resolved issues' relating to source control - still no joy, perhaps a bug report is in order.


Good luck.

Thanks again. I will try these steps and report back on what happens.

This worked...I think. I renamed the .gitfolder, and saw that XCode no longer had the app under source control. SourceTree saw no problems with the repository. I did a git init to create a new .git folder. Xcode still choked on the brand new repository. Then I did a commit from SourceTree and - voilà! - Xcode showed the app under source control, and commits now work. I had done a merge just a day or so ago, so I didn't lose anything important. It's fixed and working now, but I certainly can't say why that sequence of steps fixed it.


Thanks to all for your help.

Just for reference, I had a similiar problem: Xcode 10 would hang when trying to commit but before it could display the commit window.


I solved it by removing the file

<Project>.xcodeproj/project.xcworkspace/xcuserdata/<Username>.xcuserdatad/UserInterfaceState.xcuserstate
I fixed the detached HEAD and it worked.