栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

git仓库瘦身

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

git仓库瘦身

问题:使用git命令过去版本库文件时遇到如下错误

emote: fatal: Out of memory, malloc failed (tried to allocate 428284644 bytes)        
remote: aborting due to possible repository corruption on the remote side.
Receiving objects:  94% (5982/6334), 221.66 MiB | 5.84 MiB/s  

处理方案:
方案1、通过git命令先获取第一层的文件目录,然后再更新
方案2、版本库瘦身

# 查看历史大文件
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"
# 从历史中删除 target/ 这个文件夹
git filter-branch --force --index-filter 'git rm -r  --cached --ignore-unmatch target/' --prune-empty --tag-name-filter cat -- --all
# 执行仓库压缩
git gc --prune=now
# 推送到远程仓库
git push origin --force --all
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/729316.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号