.gitignore 文件是忽略文件,里面添加的内容是不需要上传的版本库中的。(当本地工程中的很多文件不需要提交时,配置gitignore配置文件可以用来设置在git提交时需要被忽略的文件)
创建gitignore:
1、touch .gitignore 2。open .gitignore
粘贴:
#CocoaPods
Pods/
# 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
此文件要在工程目录的根目录下创建,最外层:

其实在coding上创建项目的时候要注意将readme 和 gitignore勾选,这样拉下来的项目就含有gitignore文件了。

如果该文件不可见,可以使用以下命令:(都是全局改变)
对于OS X Mavericks 10.9:
defaults write com.apple.finder AppleShowAllFiles TRUE
对于以前的OS X版本,
efaults write com.apple.Finder AppleShowAllFiles TRUE
此时可能你会发现,即便使用了以上指令仍然看不到,那么你需要重启一下finder
指令:killall Finder
这样就能看到gitignore文件了,并把该文件提交到版本库。等再次提交代码时,里面的忽略文件就不会再出现了。
网友评论