Git忽略Xcode项目的文件 [英] Git ignore file for Xcode projects

查看:91
本文介绍了Git忽略Xcode项目的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git Xcode 结合使用时,我应该在 .gitignore 中包含哪些文件?

解决方案

Mods:请不要批准修改此答案。到目前为止,每个编辑都是不正确的,并导致数据丢失。请留下这个答案!

如果您想编辑此答案...别。首先阅读全部内容 - 您可以通过简单的方式制作自己的分支,如果这还不够,请对其进行评论。





$ b $我之前使用的是顶级投票答案,但它需要一些清理,所以在这里重做Xcode 4,并做了一些改进。



<我已经研究过这个列表中的每个文件,但其中有几个文件不存在于Apple的官方xcode文档中,所以我不得不继续使用Apple邮件列表。



Apple继续添加未公开的文件,可能会破坏我们的实时项目。这恕我直言是不能接受的,我现在开始每次他们这样记录错误。我知道他们并不在乎,但也许会让其中的一个人更加公平地对待开发者。




如果你需要自定义,这是你可以分叉的要点: https://gist.github.com/3786883




  ############### ########## 
#.gitignore文件用于Xcode4和Xcode5源项目

#Apple bug,等待Apple修复/响应:

#15564624 - Xcode5中的xccheckout文件是做什么的?文档在哪里?

#版本2.6
#最新版本,请参阅:http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects

#2015更新:
# - 修正了xccheckout一行中的错字 - 感谢@lyck指出它!
# - 修正.idea可选忽略。感谢@hashier指出了
# - 最后在忽略中添加了xccheckout。苹果仍然拒绝回答关于这方面的支持请求,但实际上似乎你应该忽略它。
# - 来自Jona和Coeur的小调整(稍微更精确的xc *过滤/名称)
#2014更新:
# - 附加的非标准项目默认情况下禁用(如果使用那些工具)
# - 删除了SO.com版主制作的编辑,而没有打扰问我
# - 更仔细地研究了CocoaPods .lock,感谢Gokhan Celiker
#2013更新:
# - 修正了破损的保存个人计划
# - 为一切(一些丢失)添加了逐行解释

#注意:如果您要存储built 产品,这不会工作,
#,你应该使用一个不同的.gitignore(或根本没有)
#这个文件是用于SOURCE项目,其中有许多额外的
#文件我们希望排除

#########################

### ##
#OS X永远不应该提交的临时文件

#cf http://www.westwind.com/reference/os-x/invisibles.html

.DS_Store

#c.f. http://www.westwind.com/reference/os-x/invisibles.html

。粉碎

#c.f. http://www.westwind.com/reference/os-x/invisibles.html

* .swp


#* .lock - 这是许多编辑使用和滥用了许多不同的东西。
#对于我使用的主要版本(例如Eclipse),它应该从源代码管理中排除
#但是YMMV。
#(锁文件通常是本地文件同步在本地FS上,不应该在git中)
#c.f.底部的可选部分虽然是针对特定工具的变体!

#特别是,如果您使用的是CocoaPods,您需要注释掉这一行:
* .lock



#个人资料 - 暂时取消(在复查时,我无法在OS X文档中找到它)
#profile


####
#Xcode暂时不应该提交的临时文件

#注意:即使在Storyboard项目中仍然存在NIB / XIB文件,所以我们希望这...

*〜.nib


####
#Xcode构建文件 -

#NB:斜线在最后,所以我们只删除FOLDER,而不是任何被错误地命名为DerivedData的文件

DerivedData /

#NB:斜线到底,所以我们只删除FOLDER,而不是任何文件这是非常名为构建

构建/


#####
#Xcode私人设置(窗口大小,书签,断点,自定义可执行文件,智能组)

#这很复杂:

#有时您需要将此文件放入版本控制中。
#Apple设计得很差 - 如果您使用自定义可执行文件,它们会保存在此文件中的
#。
#99%的项目不使用这些项目,所以他们不希望版本控制这个文件。
#..但如果你在1%,注释掉* .pbxuser这一行

#.pbxuser:http://lists.apple.com/archives/ xcode-users / 2004 / Jan / msg00193.html

* .pbxuser

#.mode1v3:http://lists.apple.com/archives/xcode-users/ 2007 / Oct / msg00465.html

* .mode1v3

#.mode2v3:http://lists.apple.com/archives/xcode-users/2007/Oct/ msg00465.html

* .mode2v3

#.perspectivev3:http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-文件

* .perspectivev3

#NB:同样,默认的白名单,一些项目需要使用这些
!default.pbxuser
!default .mode1v3
!default.mode2v3
!default.perspectivev3

$ b ####
#Xcode 4 - 半个人设置

#Apple苹果放入错误文件夹
#cf的共享数据http://stackoverflow.com/a/19260712/153422
#答案:苹果公司表示不要忽视它
#评论:苹果是错的; Apple代码太不可靠;没有任何已知的消极副作用,无视苹果的非官方建议,而是做主动修复Xcode中的错误的东西
#向您提供,但是...当前的建议:忽略它。
* .xccheckout



#选项1:--------------------- ------------
#扔掉所有个人设置(包括自定义方案!
# - 除非它们是共享的)
#根据构建/和DerivedData /,这应该有一个尾部斜线

#NB:这是在选项2下面独占
xcuserdata /

#选项2:--- ------------------------------
#摆脱所有个人设置,但保留一些
# - 注意:你必须手动取消注释你想保留的位

#注意:这*需要* git v1.8.2或更高版本;您可能需要升级到最新的OS X,
#或手动安装Git到OS X版本的顶部
#NB:这是与选项1独占的

#xcuserdata / ** / *

#(需要上述选项2):个人计划

#!xcuserdata / ** / xcschemes / *

####
#XCode 4工作区 - 更详细的

#工作区很重要!它们是Xcode的核心功能 - 不排除它们:)

#工作区布局非常垃圾。作为参考:

#/(root)/
#/(project-name).xcodeproj/
#project.pbxproj
#/project.xcworkspace/
#contents.xcworkspacedata
#/ xcuserdata /
#/(您的名字)/ xcuserdatad /
#UserInterfaceState.xcuserstate
#/ xcshareddata /
# / xcschemes /
#(共享方案名称).xcscheme
#/ xcuserdata /
#/(您的名字)/ xcuserdatad /
#(私人方案).xcscheme
#xcschememanagement.plist



####
#Xcode 4 - 弃用的类

#据称,如果你手动弃用你的课程,他们就会搬到这里。

#我们使用源代码控制,所以这是一个我们不想要的特性!

* .moved-aside

####
#可选:人们在Xcode / iOS开发中并行使用的一些着名工具

#NB:我宁愿不在这里包括这些,但gitignore的设计很弱,不允许
#modular gitignore:你必须将所有东西放在一个文件中。

#COCOAPODS:

#c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock
#c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control

#!Podfile.lock

#RUBY:

#cf http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/

#!Gemfile.lock

#IDEA:

#cf https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml

#.idea / workspace.xml

#TEXTMATE:

# - UNVERIFIED:cf http://stackoverflow.com/a/50283/153422

#tm_build_errors

####
#UNKNOWN:被别人推荐,但我可以't发现这些文件是什么


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

解决方案

Mods: Please do not approve edits to this answer. So far, every edit has been INCORRECT and causes DATA LOSS. Please leave this answer alone!


If you want to edit this answer ... don't. Read the whole thing first - there's an easy way for you to make your own fork, and if that's not enough then comment on it.


I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is re-done for Xcode 4, with some improvements.

I've researched every file in this list, but several of them do not exist in Apple's official xcode docs, so I had to go on Apple mailing lists.

Apple continues to add undocumented files, potentially corrupting our live projects. This IMHO is unacceptable, and I've now started logging bugs against it each time they do so. I know they don't care, but maybe it'll shame one of them into treating developers more fairly.


If you need to customize, here's a gist you can fork: https://gist.github.com/3786883


#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
#    15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2015 updates:
# - Fixed typo in "xccheckout" line - thanks to @lyck for pointing it out!
# - Fixed the .idea optional ignore. Thanks to @hashier for pointing this out
# - Finally added "xccheckout" to the ignore. Apple still refuses to answer support requests about this, but in practice it seems you should ignore it.
# - minor tweaks from Jona and Coeur (slightly more precise xc* filtering/names)
# 2014 updates:
# - appended non-standard items DISABLED by default (uncomment if you use those tools)
# - removed the edit that an SO.com moderator made without bothering to ask me
# - researched CocoaPods .lock more carefully, thanks to Gokhan Celiker
# 2013 updates:
# - fixed the broken "save personal Schemes"
# - added line-by-line explanations for EVERYTHING (some were missing)
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
#########################

#####
# OS X temporary files that should never be committed
#
# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.DS_Store

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

.Trashes

# c.f. http://www.westwind.com/reference/os-x/invisibles.html

*.swp

#
# *.lock - this is used and abused by many editors for many different things.
#    For the main ones I use (e.g. Eclipse), it should be excluded 
#    from source-control, but YMMV.
#   (lock files are usually local-only file-synchronization on the local FS that should NOT go in git)
# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations!
#
# In particular, if you're using CocoaPods, you'll want to comment-out this line:
*.lock


#
# profile - REMOVED temporarily (on double-checking, I can't find it in OS X docs?)
#profile


####
# Xcode temporary files that should never be committed
# 
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...

*~.nib


####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"

DerivedData/

# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"

build/


#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
#  saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
#  ..but if you're in the 1%, comment out the line "*.pbxuser"

# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html

*.pbxuser

# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode1v3

# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html

*.mode2v3

# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file

*.perspectivev3

#    NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3


####
# Xcode 4 - semi-personal settings
#
# Apple Shared data that Apple put in the wrong folder
# c.f. http://stackoverflow.com/a/19260712/153422
#     FROM ANSWER: Apple says "don't ignore it"
#     FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode
# Up to you, but ... current advice: ignore it.
*.xccheckout

#
#
# OPTION 1: ---------------------------------
#     throw away ALL personal settings (including custom schemes!
#     - unless they are "shared")
# As per build/ and DerivedData/, this ought to have a trailing slash
#
# NB: this is exclusive with OPTION 2 below
xcuserdata/

# OPTION 2: ---------------------------------
#     get rid of ALL personal settings, but KEEP SOME OF THEM
#     - NB: you must manually uncomment the bits you want to keep
#
# NB: this *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,
#    or manually install git over the top of the OS X version
# NB: this is exclusive with OPTION 1 above
#
#xcuserdata/**/*

#     (requires option 2 above): Personal Schemes
#
#!xcuserdata/**/xcschemes/*

####
# XCode 4 workspaces - more detailed
#
# Workspaces are important! They are a core feature of Xcode - don't exclude them :)
#
# Workspace layout is quite spammy. For reference:
#
# /(root)/
#   /(project-name).xcodeproj/
#     project.pbxproj
#     /project.xcworkspace/
#       contents.xcworkspacedata
#       /xcuserdata/
#         /(your name)/xcuserdatad/
#           UserInterfaceState.xcuserstate
#     /xcshareddata/
#       /xcschemes/
#         (shared scheme name).xcscheme
#     /xcuserdata/
#       /(your name)/xcuserdatad/
#         (private scheme).xcscheme
#         xcschememanagement.plist
#
#

####
# Xcode 4 - Deprecated classes
#
# Allegedly, if you manually "deprecate" your classes, they get moved here.
#
# We're using source-control, so this is a "feature" that we do not want!

*.moved-aside

####
# OPTIONAL: Some well-known tools that people use side-by-side with Xcode / iOS development
#
# NB: I'd rather not include these here, but gitignore's design is weak and doesn't allow
#     modular gitignore: you have to put EVERYTHING in one file.
#
# COCOAPODS:
#
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
#!Podfile.lock
#
# RUBY:
#
# c.f. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
#
#!Gemfile.lock
#
# IDEA:
#
# c.f. https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml
# 
#.idea/workspace.xml
#
# TEXTMATE:
#
# -- UNVERIFIED: c.f. http://stackoverflow.com/a/50283/153422
#
#tm_build_errors

####
# UNKNOWN: recommended by others, but I can't discover what these files are
#

这篇关于Git忽略Xcode项目的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆