有空整理基础知识。
1.先在github、gitlab或码云上,新建一个项目代码仓库。
注意设置好.gitignore模板。
2.复制远程仓库URL,使用Xcode,克隆到本地。
得到一个本地仓库的项目文件夹:
按shift + command + .可以查看隐藏文件(再次可隐藏)其中的.gitignore文件自动创建好了。
3.使用Xcode,在此目录中,新建一个工程。得到:
4.配置ignore
现在,来看看.gitignore文件的内容如下:
.DS_Store
.svn
profile
*.moved-aside
#CocoaPods
Pods/
!Podfile
!Podfile.lock
## Build generated
build/
DerivedData
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint
*.xcscheme
*.xcworkspace
!default.xcworkspace
DerivedData
.idea
## Obj-C/Swift specific
*.hmap
*.ipa
若需要忽略上传pod文件夹,则把# Pod/这句的#去掉。
以后再提交代码就会忽略.xcuserstate和.DS_Store文件、Pods文件夹。
补充
如果不是空项目,建议先把完整项目备份好(除.git文件夹以外的所有文件),再创建一个远程仓库,克隆,再把备份项目拷贝进去,再上传就行了。