14

I know there's an option to make a local repository for your project when you first create it, but is there an option create a repository after you've created your project?

3 Answers 3

17

Sure, just run the following command in your project directory:

git init

This will create the .git directory containing an empty repository. Then, add and commit your files.

Sign up to request clarification or add additional context in comments.

2 Comments

when I am trying to use git init i am getting -bash: git: command not found. can you please help me on this. I am using xcode 4.2
@chaitanyakiranThandu Make sure you have installed the 'Command Line Tools'. You can find them under Xcode > Preferences > Downloads > Components. Click the Install button next to Command Line Tools.
4

In the command prompt, make sure you're in the desired directory and perform a git init and you will have created an empty repository.

You can then proceed to add the files and directories to the repository by doing

git add <filename1> <filename2> ...

or you can select whole directories and use * to act as a wild card of sorts.

git add ./*

If you have any more questions check out these pages:

Hope this helps.

Comments

4

You should go to your Xcode menu, click Source Control > Create Working Copy...

Xcode will automatically create your .git folder repository.

Good luck, and make sure you have a backup of your project before trying something else.

1 Comment

Works but create a .gitignore file first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.