前言:在做項目開發(fā)時,基本都是幾人合作一起開發(fā)項目。項目肯定會用到三方框架,這個時候,要是有三方庫更新,那么你們的項目百分之九十會遇到?jīng)_突,很是煩人。
這個時候就需要我們?nèi)フ肄k法解決這種坑人的事情。
.gitignore,創(chuàng)建這個文件,可以完美解決,而且還可以讓自己的項目沒那么大
- 打開終端
cd 你的工程項目
- 創(chuàng)建.gitignore
touch .gitignore
- 進入編輯文件
vim .gitignore
- 添加要忽略的東西
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace
#CocoaPods
Pods
!Podfile
!Podfile.lock
- 最后,保存退出。
注意 .gitignore 的創(chuàng)建時機
最好是在剛剛把項目創(chuàng)建好,再來創(chuàng)建 .gitignore。當引入所需三方庫后,把項目傳入遠程倉庫時,這個時候,就沒有要上傳的三方庫文件,只有Podfile和Podfile.lock。遠程倉庫里面也沒有三方庫,當下載來后,只需要pod install一下就好
添加
補充
使用Xcode的Source Control時,老是出現(xiàn)UserInterfaceState.xcuserstat文件沒有commit的情況.
- git的文檔寫到
To stop tracking a file that is currently tracked, use git rm --cached.
可能是Git已經(jīng)在track該文件了
- 解決辦法
git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"