管理.git文件大小 [英] Managing .git file size

查看:325
本文介绍了管理.git文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.git文件已增长到229Mb,我想知道缩小尺寸的最佳方法是什么。我知道git gc,并且一直在使用它。我并不完全确定git是如何工作的,但我知道那里已经有了我不再需要的打包信息。就像,我知道我不再需要保存的前五个分支。有没有办法彻底清除旧的分支或提交或类似的东西?

)提交历史完整,然后过期,重新包装,修剪和垃圾收集:

  git reflog expire --expire = 0  - all 
git repack -ad
git prune
git gc

这应该是最小的大小,你可以让你的repo 保留你的提交历史。



如果不是,你想要或不介意重新开始回购的当前状态作为最初的承诺,那么Peter Tillemans的方法就可以做到。

My .git file has grown to 229Mb and I wondering what the best way to cut down the size is. I know about git gc and have been using it a fair amount. I'm not totally sure about how git works, but I know that there is packaged information in there that I no longer need. Like, I know I no longer need the first five branches saved. Is there a way to completely erase really old branches or commits or something like that?

解决方案

If you want to keep your (reachable) commit history intact, then expire, repack, prune, and garbage collect:

git reflog expire --expire=0 --all
git repack -ad
git prune 
git gc

This should be the minimal size you can get your repo and keep your commit history.

If not, i.e., you want or do not mind starting afresh with the current state of the repo as the initial commit, then Peter Tillemans' approach will do it.

这篇关于管理.git文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆