正文
- Git忽略規則:
#此為注釋 – 內容被 Git 忽略
.sample # 忽略所有 .sample 結尾的文件
!lib.sample # 但 lib.sample 除外
/TODO # 僅僅忽略項目根目錄下的 TODO 文件,不包括 subdir/TODO
build/ # 忽略 build/ 目錄下的所有文件
doc/.txt # 會忽略 doc/notes.txt 但不包括 doc/server/arch.txt
- .gitignore規則不生效的解決辦法
把某些目錄或文件加入忽略規則,按照上述方法定義后發現並未生效,原因是.gitignore只能忽略那些原來沒有被追蹤的文件,如果某些文件已經被納入了版本管理中,則修改.gitignore是無效的。那么解決方法就是先把本地緩存刪除(改變成未被追蹤狀態),然后再提交:
git rm -r --cached . git add . git commit -m 'update .gitignore'
下面是iOS .gitignore內容的一個示例
# # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore ## Build generated build/ DerivedData/ ## Various settings *.xcuserstate *.DS_Store *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata/ ## Other *.moved-aside *.xccheckout *.xcscmblueprint ## Obj-C/Swift specific *.hmap *.ipa *.dSYM.zip *.dSYM # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # # Pods/ # Carthage # # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts Carthage/Build # fastlane # # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the # screenshots whenever they are needed. # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/#source-control fastlane/report.xml fastlane/Preview.html fastlane/screenshots fastlane/test_output # Code Injection # # After new code Injection tools there's a generated folder /iOSInjectionProject # https://github.com/johnno1962/injectionforxcode iOSInjectionProject/
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。