当我在使用 Xcode 与 Git 结合时,应该包括哪些文件在 .gitignore
中?
当我在使用 Xcode 与 Git 结合时,应该包括哪些文件在 .gitignore
中?
xcuserstate
xcsettings
我把.gitignore文件放在项目的根目录下,与此同时,我提交并推送了代码。
接着我运行了以下命令:
git rm --cached UserInterfaceState.xcuserstate WorkspaceSettings.xcsettings
下面是被隐藏的文件夹:
<my_project_name>/<my_project_name>.xcodeproj/project.xcworkspace/xcuserdata/<my_user_name>.xcuserdatad/
### Xcode ###
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate
### Objective-C ###
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
Pods/
gitignore.io: 为你的项目创建有用的 .gitignore 文件
Objective-C
Swift
SwiftPackageManager
Carthage
Xcode
macOS
Create Git global config alias (One time only)
git config --global alias.ignore '!gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi'
Enter the project directory
cd <the project directory>
Generate .gitignore file
git ignore Objective-C,Swift,SwiftPackageManager,Carthage,Xcode,macOS >.gitignore
Add and commit .gitignore file
git add .gitignore
git commit -m "Add .gitignore file"
.gitignore
:
https://github.com/github/gitignore/blob/master/Objective-C.gitignore
它在任何时候都应该是相当正确的。
我建议使用joe来生成.gitignore
文件。
对于iOS项目,请运行以下命令:
$ joe g osx,xcode > .gitignore
它将生成这个.gitignore
文件:
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
build/
DerivedData
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
*.xcuserstate
npx gitignore Objective-C
-bash: npx: command not found
- Mark这将创建最新的gitignore文件
适用于iOS开发
git ignore swift,ios >.gitignore
针对 macOS 开发
git ignore swift,macos >.gitignore
我们发现即使添加了.gitignore和.gitattribte文件,*.pbxproj文件仍然可能会损坏。因此,我们有一个简单的计划。
每个在办公室编码的人都会简单地放弃对该文件所做的更改。在提交时,我们只提到添加到源中的文件。然后推送到服务器。我们的集成经理随后拉取并查看提交详细信息,并将文件添加到资源中。
一旦他更新了远程,每个人都将始终拥有一个可工作的副本。如果缺少某些内容,则通知他添加并再次拉取。
这对我们来说没有任何问题。
https://www.gitignore.io/api/swift,xcode,Cobjective-c,osx
。该网页提供了相关的忽略文件,可用于在Git中排除Swift、Xcode、C Objective-C和OSX等方面的文件。 - geekay