Git 【.gitignore】

6 篇文章 3 订阅

常常我们在本地 git 仓库中管理的一部分文件不需要上传到远端仓库,毕竟我们提交的只是代码部分。一些第三方体积较大、一些无关紧要的文件,都是不需要上传到远端仓库的。所以说我们可以忽略掉,也就是常说的 .gitignore。最好的方式就是创建一份自己的 .gitignore 文件,然后把常用的忽略文件 copy 到上面就可以了。


就比如说下面的终端命令提示中,我们提交的部分包含了 Pods 中的三方代码,超过了 100MB 而导致提交失败。

wangzhongyao:eHighSpeed wangzhongyao$ git push origin master
Counting objects: 1538, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1498/1498), done.
Writing objects: 100% (1538/1538), 156.55 MiB | 1.45 MiB/s, done.
Total 1538 (delta 218), reused 17 (delta 4)
remote: Resolving deltas: 100% (218/218), done.
remote: Powered by Gitee.com
remote: warning: Large files detected.
remote: error: File Pods/AMap3DMap/MAMapKit.framework/MAMapKit is 126.44 MB; this exceeds file size limit of 100.0 MB
remote: error: hook declined to update refs/heads/master
To gitee.com:yigaosu/eHighSpeed.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'git@gitee.com:yigaosu/eHighSpeed.git'


所以:

① 创建自己的 .ignore 文件:

cd 到自己项目下,然后 touch .gitignore


② 配置 .ignore 文件,下面是我用到的需要忽略掉的部分文件:

# Xcode
.DS_Store
*.DS_Store
._.DS_Store
*/Lib/*
BPB/Classes/Lib/
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace
*.xcuserstate  
project.xcworkspace   
UserInterfaceState.xcuserstate  
project.xcworkspace/  
xcuserdata/  
UserInterface.xcuserstate

#CocoaPods
Pods
Podfile
Podfile.lock

## Build generated
build/
DerivedData/
*/build/*

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xcuserstate

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM


再另外对上面的忽略文件做一下说明:

#   注释符

*.xxx   忽略以 xxx 结尾的文件

*/Lib/*   忽略 Lib 文件夹下的所有文件(不考虑 Lib 文件夹究竟在那里)

Podfile   直接忽略掉 Podfile 文件


基本上我在项目中用到的就是这些,不足之处欢迎大家提出补充。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值