我最近遇到了Bitbucket repo的大小限制.我跟着无数其他问题回答了如何清理你的git repo并最终使用BFG来删除一些糟糕的提交.
这很好用,但是,我注意到在运行git计数后,垃圾中有大量的空间.所以我运行了一个简单的git gc.然而,这没有什么可以清理垃圾.
经过一番挖掘后,我找到了以下命令:
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 \
-c gc.rerereunresolved=0 -c gc.pruneExpire=now gc "$@"
Run Code Online (Sandbox Code Playgroud)
运行此操作导致垃圾在本地清理.但是,我仍然有远程回购的问题.我现在需要让Bitbucket在我的远程仓库上运行此命令,还是有办法将此更改推送到存储库?
Jan*_*ski 36
我们认为我们今天遇到了同样的问题,并且能够在不联系Bitbucket支持的情况下解决问题,如下所示.请注意,该方法会从repo中丢弃最后一次提交 - 因此您可能希望拥有其备份.
据Bitbucket报道,我们的回购约为2.1GB,而克隆时,它本地只需要大约250MB.由此,我们得出结论,它最有可能来自无法访问的大文件(感谢这个答案).
这是如何在本地查看无法访问的提交,我们没有考虑通过reflog的可达性:
git fsck --unreachable --no-reflog
在本地,无法访问的提交可以通过以下方式清除:
git reflog expire --expire-unreachable="now" --all
git prune --expire="now" -v
git gc --aggressive --prune="now"
Run Code Online (Sandbox Code Playgroud)
但是,我们无法在Bitbucket上远程运行任何这些命令.但是,他们在页面上说减少回购大小(删除存储库限制),他们自己运行git gc以响应执行git reset --hard HEAD~1(丢弃最后一次提交),然后执行git push -f.此外,他们在一节说,垃圾收集死者的数据,一个可以尝试的序列: git reflog expire --expire=now --all, git gc --prune=now, git push --all --force.鉴于这一切,我决定尝试以下本地,希望它删除reflog并在本地进行修剪,然后将它们推送到远程Bitbucket存储库,在它上面启动一个gc:
git reflog expire --expire-unreachable="30m" --all
git prune --expire="30m" -v
git gc --prune="30m"
git reset --hard HEAD~1
git push -f
Run Code Online (Sandbox Code Playgroud)
这个工作,回购大小立即从2.1GB到大约.250MB.:)
请注意,到期/ expire-unreachable/prune的时间参数设置从现在开始测量的到期截止点.所以例如"现在"意味着过期/修剪一切,"30m"意味着除了最后30分钟的变化.
如果其他人遇到这种情况,答案结果是肯定的.
Bitbucket支持运行如下:
git reflog expire --expire="1 hour" --all
git reflog expire --expire-unreachable="1 hour" --all
git prune --expire="1 hour" -v
git gc --aggressive --prune="1 hour"
Run Code Online (Sandbox Code Playgroud)
之前和之后将远程仓库大小从2GB以上减少到1GB以下.
| 归档时间: |
|
| 查看次数: |
10203 次 |
| 最近记录: |