在远程新建一个工程仓库之后,使用git clone拉取下来,然后把工程文件移动到文件夹下(该工程使用了Cocoapods,.xcworkspace,Podfile,Podfile.lock,Pods文件夹是Cocoapods相关),如下:
将工程目录拖动到SourceTree(git提交可视化工具),可以看到文件状态下有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文件。