.hgignore for Mac OS X applications
If you use version control (and you should), then you're familiar with the pollution that an Xcode build folder can put into your status output:
? build/.DS_Store ? build/Debug/UTI Plist Helper.app/Contents/Info.plist ? build/Debug/UTI Plist Helper.app/Contents/MacOS/UTI Plist Helper ? build/Debug/UTI Plist Helper.app/Contents/PkgInfo ? build/Debug/UTI Plist Helper.app/Contents/Resources/English.lproj/InfoPlist.strings ? build/Debug/UTI Plist Helper.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib ? build/Debug/UTI Plist Helper.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib ? build/Debug/UTI Plist Helper.app/Contents/Resources/English.lproj/MainMenu.nib/keyedobjects.nib â‹®
Good version-control systems offer a way to ignore any file that matches a certain pattern. In the case of an Xcode project, you want to ignore the build folder and a few other things: .DS_Store files, backup nibs (those Foo~.nib packages that IB creates when you save), etc.
In Mercurial, the way to do that is to create a .hgignore file, and populate it with the patterns you want hg to ignore.
In order to save you repetitive work, here's a .hgignore file, already fully-populated, that you can use when versioning your Xcode-based project with Mercurial:
What to do with this file
- Download it, and save the .bz2 file somewhere such as your Documents folder.
- cd into the top level of a repository.
- Extract the file using this command line: bunzip2 < ~/Documents/hgignore.bz2 > .hgignore
- Add the file: hg add .hgignore
- Commit it.
Thereafter, not only do you have a .hgignore file keeping your status output clean, but it's versioned, so it's easy for you to track and revert changes to the ignore file over time.
March 20th, 2008 at 10:05:05
I use git, so not sure if syntax is the same but you might want to exclude default.pbxuser from your all inclusive *.pbxuser
Also shouldn't it be *.perspectivev3 these days?
March 20th, 2008 at 10:37:57
Mark: Having a .hgignore doesn't prevent you from versioning files that match an ignore pattern. If you have a default.pbxuser that you want to version, go right ahead and do that—nothing's stopping you.
As for .perspectivev3: Yup, you're right. I'm still developing primarily on Tiger, so I forgot about that. I'll update the file and the post with it.
March 22nd, 2008 at 10:34:23
According to hgrc(5), you can put
[ui]
ignore = ~/.htignore
in your ~/.hgrc, and have this apply to all of your projects automatically.
March 22nd, 2008 at 10:46:14
Andrew: Sure, but then each developer has to repeat that process. If you version .hgignore instead, they get its benefits automatically, from the moment they clone your repository.
Of course, this way, you have to do it for each new project. It's a trade-off. I think this way results in less work over the long term.
June 10th, 2008 at 10:40:35
I would like to use only one ignore file: ~/.hgignore. But then again I'd like it to ignore all files that have a tmp or temp soewhere within there path. Any idea how to achieve this?
June 11th, 2008 at 09:11:57
Till: Read Andrew's comment, and use a regex pattern:
syntax: regexp
.*/te?mp/.*