Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a git repository in Xcode for a pre-existing project [duplicate]

Possible Duplicate:
Using Git with an existing Xcode project

Setting up a git repository in Xcode after a project was created. (i.e. you did not create a git repository when creating the project)

like image 410
Joey Avatar asked Jun 13 '12 19:06

Joey


People also ask

How do I Clone a GitHub repository in Xcode?

Once you authenticate into Xcode with your GitHub account, the “Open in Xcode” button will appear for relevant repositories on GitHub. Click the button and Xcode will launch, prompting you to choose a directory to clone the repository to your local machine. Happy cloning!

How do I add a Git repository to my existing Xcode?

Push your projectGo to Source Control in Xcode and select Projectname -- master, then Configure... In the Address field, paste the Git clone URL for your repo copied in the previous step. Select Add Remote, then select Done to finish creating the origin remote for your local Git repo.


2 Answers

Last answer works OK, but is rather lengthy and incompatible with newer Xcode versions. I will try to reiterate it better:

  1. Choose your git repository folder (directory) usually this will be the directory containing the Xcode workspace or project.
  2. In that directory, create a text file named ".gitignore", and put the following contents into it:

    UserInterfaceState.xcuserstate build *.pbxuser *.perspectivev3 *.mode1v3 *~ *~.nib *~.xib  .DS_Store  xcuserdata/ 
  3. Quit Xcode (If it was open)
  4. In Terminal do the following:

    \> cd <path of the repository folder> \> git init \> git add . \> git commit -m "Initial commit - or whatever text you'd prefer" 

You're done! Open the workspace/project in Xcode and examine your repository in the organizer window.

like image 90
Motti Shneor Avatar answered Oct 18 '22 15:10

Motti Shneor


  1. Quit Xcode (not sure if this is necessary but I do it just in case)
  2. Run Terminal
  3. Get into the project folder directory
  4. find .
  5. Find the file that says "UserInterfaceState.xcuserstate" and copy the entire filename up to the ./
  6. echo "paste the UserInterfaceState.xcuserstate file here" >.gitignore
  7. cat .gitignore
  8. git init
  9. git add .
  10. git commit -m "You can type a comment here like now under source control"

You now have a repository and your project is under source control

like image 29
Joey Avatar answered Oct 18 '22 16:10

Joey