在遠程新建一個工程倉庫之后,使用git clone拉取下來,然后把工程文件移動到文件夾下(該工程使用了Cocoapods,.xcworkspace,Podfile,Podfile.lock,Pods文件夾是Cocoapods相關),如下:
將工程目錄拖動到SourceTree(git提交可視化工具),可以看到文件狀態(tài)下有468個新文件需要提交(其中包括了pod文件,pod文件是需要忽略的),如下:
開啟終端,CD進入到工程目錄下,使用
touch .gitignore
新建.gitignore文件,然后使用
open .gitignore
打開.gitignore文件,如下:
在打開的.gitignore文件中粘貼下列代碼(在gitignore.io中輸入相關語言可以生成),然后保存退出。
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
# Mac OS X Finder and whatnot
.DS_Store
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
*.xccheckout
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
#CocoaPods
Pods/
最后面的
#CocoaPods
Pods/是我們指定忽略pod文件。