## Monday, 10 September 2012

### Creating Git repository for existing XCode projects

This problem has been puzzling me for a while...

Scenario 1:
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?

Scenario 2:
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 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...)