标签云

微信群

扫码加入我们

WeChat QR Code

Which files should I include in .gitignore when using Git in conjunction with Xcode?


Check https://www.gitignore.io/api/swift,xcode,Cobjective-c,osx

2018年08月20日42分55秒

You shouldn't be ignoring *.lock or Podfile.lock (never mind the redundancy). You want the exact same versions installed in all workspaces, you don't want the "latest version".

2018年08月20日42分55秒

I have removed the Podfile part. I didn't add that originally, SO says someone else added it and I carelessly copy/pasted it into the gist. My apologies for any/all confusion and misunderstanding. I really dislike the way StackOverflow lets anyone edit your answers :(.

2018年08月20日42分55秒

There's now an explanation line for EVERYTHING, line by line. This should make it much clearer, and make it easier to customize for your own projects.

2018年08月20日42分55秒

Hi! update for Xcode5: Just add *.xccheckout to this file.

2018年08月20日42分55秒

Adam As I can see, this file contains VCS metadata, and should therefore not be checked into the VCS. No, there no mentions on developer.apple.com about xccheckout. But on official github page, this file included already in the gitignore file. https://github.com/github/gitignore/blob/master/Objective-C.gitignore

2018年08月20日42分55秒

I don't particularly like the .pbxuser/.perspective/*.perspectivev3 patterns. I much prefer the following .xcodeproj/ !*.xcodeproj/project.pbxproj That ignores everything inside a *.xcodeproj except the project.pbxproj.

2018年08月20日42分55秒

I do not ignore *.pbxuser, *.perspective and *.perspectivev3 because I like to keep those settings back when I clone my repository.

2018年08月20日42分55秒

Also you might want to add that you can make a "global" gitignore file like this: git config --global core.excludesfile ~/.gitignore

2018年08月20日42分55秒

I'd like to caution everyone who added .gitignore file after they have committed the project: those files you ignore are still being tracked. You'll have to remove them from git manually using git rm --cached <files>

1970年01月01日00分03秒

SpacyRicochet: Comment formatting has apparently changed since I wrote the comment. Hence the italics. My pattern is supposed to look like *.xcodeproj/* !*.xcodeproj/project.pbxproj. Of course, these days you do need to adjust it for workspaces.

2018年08月20日42分55秒

I do have the build folder outside of the project folder, but when other users build the project, it by default is recreated in the project- so I found that adding it to the ignore file is a better solution, otherwise it gets readded in their commits.

2018年08月20日42分55秒

If you just add xcuserdata, then that takes care of both.

2018年08月21日42分55秒

For some reason just adding xcuserdata without the prefix didn't work for me. I thought it should, though. Odd.

2018年08月20日42分55秒

Also one of the Github guys has collected some .gitignore files. Here is the Objective-C specific one- github.com/github/gitignore/blob/master/Objective-C.gitignore

2018年08月20日42分55秒

Also the Thoughtbot folks came up with this project - github.com/thoughtbot/liftoff which will add a sane default .gitignore files, see their blog post on it: robots.thoughtbot.com/post/33796217972/…

2018年08月20日42分55秒

This has already been posted to one of the answers above. I found it to be: incorrect, questionably supported (more than 100 outstanding pull requests!), and undocumented. The fact that it's "incorrect" is the worst of all; they have made an ignore that only works for a narrow set of uses and haven't explained what or why! Hence: my answer above, which corrects their bugs AND explains what's being done and why, so you can make educated decisions on a project-by-project basis (on a new project, I sometimes forget why some of the items are in there - the comments help me decide :))

2018年08月21日42分55秒

Adam: GitHub's .gitignore has now been updated for Xcode 6.3.2 and Swift, so it's now correct. It's also documented.

2018年08月20日42分55秒

yeah, but the problem with publishing a data-destructive file and keeping it that way for months or years - and apparently not bothering to test it properly - is that you permanently sacrifice all faith, trust, respect from the community. Too late.

2018年08月20日42分55秒

always use your example. nice settings! Thanks!

2018年08月20日42分55秒

Very useful answer. I added it as a link in my Setting Up Github in Xcode answer.

2018年08月21日42分55秒

Suragch thank you :) appreciate your feedback. will try to keep sharing knowledge.

2018年08月20日42分55秒

Did you add it also? Or is this just all you do?

2018年08月20日42分55秒

Yes, I added both but xcusersate was the main offending file. Adding that was the only way I could push my code remotely. Otherwise I was stuck in a feedback loop that required commit before push. So you commit, then Xcode 4.5 would ask you to commit again and you are never able to push because the pre req is committing.

2018年08月20日42分55秒

The github .gitignore file is a collection of all files which we had problems with in the past. Right now, if you start a Xcode project from scratch an let Xcode preconfigure the git repository, there's not too much left to ignore in .gitignore: The only thing I prefer to ignore is xcuserdata/ ... this helps not to clutter your commits.

2018年08月20日42分55秒

GitHub is the first place I ever look for gitignores :)

2018年08月20日42分55秒