赞
踩
Git LFS(Large File Storage) 是 Github 开发的一个 Git 的扩展,用于实现 Git 对大文件的支持
简单的说,就是如果你想传超过100M的二进制文件到GitHub,你就要用Git LFS!
首先确保电脑已经安装了Git并且版本不低于1.8.5
下面为不同平台的安装方法:
Linux
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install
Mac
(
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install git-lfs
git lfs install
本人为mac版本,在安装时候发生了权限错误问题,提示“
fatal: cannot copy '/usr/local/git/share/git-core/templates/hooks/pre-receive.sample' to '/usr/local/Homebrew/.git/hooks/pre-receive.sample': Permission denied
”解决办法:https://stackoverflow.com/questions/40592463/homebrew-install-fails-while-copying-files)
Windows
git lfs install
可以通过命令“git lfs version”来查看git lfs是否安装完成
下面开始添加大文件到git lfs
所有的步骤都完成了
进行到上面第五步git push之后依然提示,文件超过100M,上传失败之类的错误信息,如下
wodeMacBook-Pro:xxx$ git push origin master
Uploading LFS objects: 100% (1/1), 137 MB | 0 B/s, done
Counting objects: 111, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (110/110), done.
Writing objects: 100% (111/111), 56.71 MiB | 174.00 KiB/s, done.
Total 111 (delta 21), reused 0 (delta 0)
remote: Resolving deltas: 100% (21/21), completed with 4 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: de35e860e6f088f7ca549a40b47655df
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File xxx/aaa is 130.82 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/xxx
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/xxx'
那你可能跟我一样,是在添加大文件100M之后,并且push失败了才下载的git lfs并且添加aaa到git lfs的。
只需要放弃之前添加aaa大文件那次的commit,重新提交文件就可以了
如何撤回commit,可以参考下面的文章
https://blog.csdn.net/quiet_girl/article/details/79487966
比如我自己的操作:
wodeMacBook-Pro:xxx$ git log
wodeMacBook-Pro:xxx$ git reset --hard ac89782e303fd38f423edc678dec823d43a65f35
wodeMacBook-Pro:xxx$ git lfs track "xxx/aaa"
wodeMacBook-Pro:xxx$ git add .
wodeMacBook-Pro:xxx$ git commit -m "add aaa"
wodeMacBook-Pro:xxx$ git push
如果你是要上传比较大的framework库文件,需要主要的是,framework是一个库文件,二进制文件是包含在里面的,直接添加framework到git lfs是没有用的,需要添加里面的二进制文件
比如我想添加GoogleMobileAds.framework
wodeMacBook-Pro:xxx$ git lfs track "XXX/ADs/GoogleMobileAds.framework/GoogleMobileAds"
这样就可以了
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。