Add git tracking to an existing Xcode project

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

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:

Then open it in your favourite text editor.

I think it should at least contain:

You may also add:

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

5) Finally, commit these files