目前iOS 項目 主要忽略 臨時文件、配置文件、或者生成文件等,在不同開發端這些文件會大有不同,如果 git add .把這些文件都push到遠程, 就會造成不同開發端頻繁改動和提交的問題。
步驟:
1 . 在工程目錄下
2 . touch .gitignore //在目錄下生成.gitignore 文件
3 . open .gitignore //打開.gitignore (txt)文件
4 . 寫入忽略目錄
4.1 這里iOS 項目,使用
CocosPods 框架管理工具會生成
Podfile、
Podfile.lock、
Pods文件夾和
.xcworkspace四個。其中:
以上除
"其中
因為
Podfile外,其它三個文件都不是必須提交的。
"其中
Pods目錄沒必要提交,里面的文件都是根據
Podfile描述的依賴庫的配置信息下載和生成的文件。
因為
CocoaPods支持語義化版本號,所以需要
Podfile.lock文件記住當前使用的版本,當然這個文件也不是必須。不過提交這個的好處是,可以提醒團隊里面的人,依賴庫版本已經更新”。
(1)我們現在配置 設定 忽略依賴庫緩存目錄Pods/
忽略目錄寫法如下:
#CocoaPods
Pods/
(2)xcode相關不需要提交的配置。
# 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
(1)和(2)放一起構成我的.gitignore文件
(3)但是如果你需要忽略的文件意境存在在遠端中了,那么你需要將遠端中的文件刪除掉才可以:
使用 git rm -r --cached Pods/ //進行刪除
git rm –cached 把文件.DS_Store從git的索引庫中移除,但是對文件.DS_Store本身並不進行任何操作也就是說本地還是有.DS_Store文件的,但是遠端卻沒有了
之后再使用git commit /push //之后提交上去
這樣就不會再用擔心這個文件的沖突了
參考
1 . http://www.cnblogs.com/ShaYeBlog/p/5359849.html
2 . https://segmentfault.com/q/1010000003041610
