GIT上传大文件

2019-03-23  本文已影响0人  seawish

描述

GIT上传超过100M的大文件时,会报错:

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.

解决方案有三种:

1. 大文件不入库

参考github官方解决方案Working with large files
将大文件从git中删除,并修改commit

git rm --cached giant_file
# Stage our giant file for removal, but leave it on disk

git commit --amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well

git push
# Push our rewritten, smaller commit

如果大文件在更久的仓库历史中已经存在,可以使用BFG(git-filter-branch)命令。

bfg --strip-blobs-bigger-than 50M
# Git history will be cleaned - files in your latest commit will *not* be touched

2. 大文件入库

使用git-lfs(Git Large File Storage)工具支持超过100M的大文件上传。

# 1、安装git-lfs
brew install git-lfs

# 2、没有特别说明的情况下,LFS 不会处理大文件问题,因此,我们必须明确告诉 LFS 该处理哪些文件。将 FrameworkFold/XXXFramework/xxx的文件设置成大文件标示。
git lfs track "FrameworkFold/XXXFramework/xxx"

# 3、常规的push操作
git add .
git commit -m "add large file"

3. 撤销commit,忽略文件

# 回退commit到某个版本
# git log查看commit日志
git reset --mixed HEAD^

在.gitignore文件中忽略大文件

*.log
*.csv

参考文献

Git上传大文件


本文作者: seawish
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!

上一篇下一篇

猜你喜欢

热点阅读