When creating a new project on Xcode 4, you are given the opportunity to activate git versioning for this project.
You might have not checked this option in the first place and wish to add git tracking to the project later. Here is how to do it:
1) Open a Terminal window and go to the Project’s directory (the one that contains the .xcodeproj).
2) Type
-
git init
This adds git version control to the directory and creates a .git repository. The project is now under version control.
3) Some files which should not be versioned. git uses a .gitignore text file for that purpose which contains a list of files (you may use wildcard characters).
To edit .gitignore, you may create an empty file:
touch .gitignore
Then open it in your favourite text editor.
I think it should at least contain:
.DS_Store
You may also add:
MyProject.xcworkspace/xcuserdata/
Because you do not want information specific to a user (e.g. the list of breakpoints) to be pushed to a remote git repository.
4) To track project files (in other words, add them to the “staging area”), type
git add .
5) Finally, commit these files
git commit -m "Initial commit"