Why Create Git Repositories in Xcode freezes?

Hello guys,


It should be possible when you open Xcode project which is currently not under Git source control to go to menu Source Control > Create Git Repositories... then select the project and click Create. This should create Git repo on my Mac.


Unfortunately mine Xcode freezes there, after I click Create the window just stays there with buttons greyed out for ever. It is not possible to terminate the process, not possible to Quit from Xcode, normally.

I can only Force Quit from Xcode which takes me back on Desktop.


I'm on MacBookPro14,3 with latest updates of Catalina macOS 10.15.4 (19E266) and Xcode Version 11.4 (11E146) and I'm using standard Git version 2.24.1 (Apple Git-126) coming with Xcode.


When I Create a new Xcode project and I check to create Git repository on my Mac right from beginning than everything works fine. But I'm looking for the way to put some existing projects under Source Control, where Git was not enabled initially.


I tried also to do this manually from Terminal with 'git init'. It works, kind off, but then in Xcode it doesn't seem to be working properly.


Anyone else experiencing this issue, anyone have an advice how to make it work? Thank you in advance.


MacBook Pro 15", macOS 10.15

Posted on Apr 1, 2020 11:05 PM

Reply
Question marked as Top-ranking reply

Posted on Apr 2, 2020 1:02 PM

I can reproduce the issue on Xcode 11.4. After Xcode restarts the project is under version control, but it would be annoying to have to restart Xcode for each existing project you want to place under version control. I recommend filing a bug report with Apple, which you can do in Xcode by choosing Help > Report an Issue.


Until the issue gets fixed, I recommend creating repositories from another Git client, such as Fork or SourceTree, or from the Terminal. In Fork choose File > Create New Local Repository and choose your project folder.


If you want help with your issue from the Terminal, you need to be more specific. What folder were you in when you called git init? What do you mean by "It works, kind of"? What do you mean by "in Xcode it doesn't seem to be working properly"? No one can help you if you don't provide more detail on the statements you made in the second to last paragraph.

5 replies
Question marked as Top-ranking reply

Apr 2, 2020 1:02 PM in response to Manolis_from_Prague

I can reproduce the issue on Xcode 11.4. After Xcode restarts the project is under version control, but it would be annoying to have to restart Xcode for each existing project you want to place under version control. I recommend filing a bug report with Apple, which you can do in Xcode by choosing Help > Report an Issue.


Until the issue gets fixed, I recommend creating repositories from another Git client, such as Fork or SourceTree, or from the Terminal. In Fork choose File > Create New Local Repository and choose your project folder.


If you want help with your issue from the Terminal, you need to be more specific. What folder were you in when you called git init? What do you mean by "It works, kind of"? What do you mean by "in Xcode it doesn't seem to be working properly"? No one can help you if you don't provide more detail on the statements you made in the second to last paragraph.

Apr 4, 2020 12:56 PM in response to Manolis_from_Prague

I don’t recommend using the git integration inside Xcode at all. Xcode’s SCM integration has gotten steadily worse with each release over the past few years.


You will have to manually add all of your files to git using the Terminal.


Here is my .gitignore file that I’ve cobbled together from various sources. Make sure this is in place before you do anything in git.


# OS X Finder

.DS_Store


# Xcode per-user config

*.mode1

*.mode1v3

*.mode2v3

*.perspective

*.perspectivev3

*.pbxuser

xcuserdata/


# Build products

build/

*.o

*.LinkFileList

*.hmap


# Automatic backup files

*~.nib/

*.swp

*~

*.dat

*.dep


Hopefully this works for you. I’ve had to edit it very recently because Xcode was storing yet another per-user config file deep inside some project folder.


Do NOT trust Xcode for SCM. Some simple git commands, like adding or renaming, will take minutes per file. Other times, Xcode will just forget a file was under git in the first place. This is annoying because then the “code review” button doesn’t work. If Xcode hasn’t scrambled itself too badly, you can use the “code review” button. But for anything else, I use the Terminal. Twice recently I’ve had to drive back to work and commit and push files on the command line that Xcode didn’t.

Apr 6, 2020 10:22 PM in response to Manolis_from_Prague

I have just encountered the same issue you describe while attempting to create a git repository for an existing Xcode Workspace – Xcode freezes with no success indication, and then upon restarting Xcode, some files are added in the repository but the majority are not included.


It appears this may have been a new breaking change with Xcode 11.4 as I cannot find any other online discussion from previous versions.


Do please keep this thread updated with your findings from the bug report you filed, I am eager to find a resolution so I can place my project under source control directly from Xcode without an external solution.

Apr 2, 2020 1:46 PM in response to Mark Szymczyk

Hello Mark,


Thank you very much for reply and that's what I did already, I have filed bug to Apple this morning, so let's see if some information comes.


What I mean with "works, kind of.?" Well...


problem is, if I create Git repo from command line with 'git init' from the base folder where my Test.xcodeproj is located, manually, from now onwards I never end up with 'git status' saying 'nothing to commit, working tree clean'.


All the time without changing anything in source files, storyboard, no changes in Xcode settings, nothing - all the time when I check 'git status' I'm getting following output:


On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   Test.xcodeproj/project.xcworkspace/xcuserdata/Manoli.xcuserdatad/UserInterfaceState.xcuserstate

no changes added to commit (use "git add" and/or "git commit -a")


And after another commit, I get it again, and again... over and over.


Fortunately this does not happen when Git repo is initialized by Xcode right from beginning when creating new project.


So I think there's something (I don't know what) not right with Xcode Source Control, when repo is created manually from command line... or am I doing something wrong?


Have good evening, bye.


Apr 4, 2020 3:47 PM in response to etresoft

Wau, thank you very much etresoft!


Absolutely, I'll give it a shot, the list of .gitignore is really helpful.


Also thanks for an advice, I'll be careful with Xcode, so far I can't complain to much.


Just only the problem with freeze when creating git repositories on already existing projects. I've posted that as bug via Feedback (probably like many others).


But otherwise I like Git integration in Xcode. I would say I use it a lot, and I see some nice handy features, very easy to read and spot essential information. I know it basically provides same functionality, just sometimes way more convenient than it is from command-line.


Thank you again for .gitignore and have nice day, bye...

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Why Create Git Repositories in Xcode freezes?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.