Setting up a git repository in Xcode for a pre-existing project
Last answer works OK, but is rather lengthy and incompatible with newer Xcode versions. I will try to reiterate it better:
- Choose your git repository folder (directory) usually this will be the directory containing the Xcode workspace or project.
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/
- Quit Xcode (If it was open)
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.
- Quit Xcode (not sure if this is necessary but I do it just in case)
- Run Terminal
- Get into the project folder directory
- find .
- Find the file that says "UserInterfaceState.xcuserstate" and copy the entire filename up to the ./
- echo "paste the UserInterfaceState.xcuserstate file here" >.gitignore
- cat .gitignore
- git init
- git add .
- 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