Including a .gitignore file in your Xcode project helps to keep your git repository clean and your commits effective.
Git is the default version control system, seamless integrated into Xcode since Xcode 4. So it is quite easy to develop your iOS projects under git version control. I use the free Git GUI client SourceTree from Atlassian to get a good overview over commits, branches & file status. But, but to keep the repository clean and the commits focused on real code changes, I always use a .gitignore file. This .gitignore file is also included to the git repository as it ensures that The mechanism is easy it tells git which files to ignore 🙂 The difficult part is to decide, which files should be ignored by git.
In Xcode 6 Apple did a pretty good job to clean up the project folder an only keep files which are relevant. They already excluded two file patterns from git by adding them to the .git/info/excludes file in your project directory. This file normally looks like this:
So, my personal .gitignore file is quite small these days (see old posting with .gitignore for Xcode 4) and only excludes one type of files:
xcuserdata… which ignores my personal Xcode user settings
Changes in those files / directories should not be tracked or shared with team members, as this would clutter the git repository. But thats my opinion … there may be others :-). Like some of you also add
*.xccheckout … but I only stick with the files which really trouble me and my team.
# IMPORTANT: If you committed to the git repository before you added this .gitignore file # you need to delete the excluded files manually from your git repository, to ensure, # that they are not tracked anymore. To delete them from git, just do the following: # # git rm --cached FILENAME # # ... Then everything should be fine. # Exclude personal Xcode user settings xcuserdata
If you committed to the git repository before you added this .gitignore file you need to delete the excluded files manually from your git repository, to ensure, that they are not tracked anymore. To delete them from git, just do the following and everything should be fine:
git rm --cached FILENAME