.gitignore file, where should I put it in my xcode project?

Mauricio Alberto Barragn Huert picture Mauricio Alberto Barragn Huert · Mar 12, 2012 · Viewed 55.1k times · Source

I want git to ignore my UserInterfaceState.xcuserstate file in my XCode4 project, but where should I put the .gitignore file?, is it inside the .git folder? or out? The .git is in same folder with the ProjectName.xcodeproj file

Answer

Daniel Ribeiro picture Daniel Ribeiro · Mar 12, 2012

You can have a .gitignore in every single directory of your project.

However, the best practice is to have one single .gitignore file on the project root directory, and place all files that you want to ignore in it, like this:

ignoredFile.whatever
ignoredDirectory/*
directory/ignoredFileInsideDirectory
.svn

Once you create the .gitignore file, the ignore files that have changes or are new into the repository will not be shown to as waiting for commit.

You can also have one global local git ignore file, that will manage all of your git repositories.

git config --global core.excludesfile ~/.gitignore_global

This alternative is particularly interesting for ignored files that are non-project related, such as IDE related files and so on.