You started a simple project just for a quick/simple test.
XCode gives you option to "Create local git repository for this project", and for some reason you didn't/forgot to tick it...
After you spent some time on it, your simple proof-of-concept project seems to worth a lot more now and you want to add it to the source control. Ooops, how do you do that again??!! You tried every possible options under "File -> Source Control" menu but none of them works, what the....$%#@!
I guess it's mainly your fault for not creating the repository at the beginning, but, but, but, wouldn't it be nice if Apple can add an option into XCode to make it easier to add existing projects to the the source control?
There's another scenario - which happens to me quite a lot - you downloaded something from the web, you "heavily" modified it (it's mine now, mine mine mine! Ha ha ha....), and again, later wants to add it to source control and..... stuck again!
Finally found a solution today, thanks to this link by Ash Furrow, I learned that you have to:
(a) create an empty repository by open a terminal, go to your project directory and run the following commands:
git init git add . git commit -m "Initial commit"
(b) after that, follow the following steps (you may compress the whole project into a ".gz" file first if you worried about loosing anything...)
- Move your existing project folder to your desktop.
- Make a new, empty project in Xcode with the same name as your project. Make sure the box for using a .git repo is selected.
- Close Xcode.
- Copy all files from the project folder on your desktop to the new project folder Xcode created.
- Double-click the project file.
- You'll now need to add all the files to the source control since (they'll all have question marks beside them, shown right).
And you are done! Yeah, problem solved!