删除提交以减小存储库大小的方法 [英] Method to delete commits for reducing repository size

查看:84
本文介绍了删除提交以减小存储库大小的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用git存储库将.jar文件传送到客户端.如果我不删除旧的提交,则存储库的大小会变大,最终,Bitbucket会禁用任何新的提交.这就是我一直交付文件的方式:

I am using a git repository to deliver .jar files to a client. If I don't delete the old commits, the repository size gets bigger and eventually, Bitbucket disables any new commits. This is how I have been delivering the files:

git reset --hard HEAD~
git push -f origin some-branch
git commit -m "Some message"
git push origin some-branch

基本上,最后一次提交始终只包含.jar文件,我将其删除,强制推送从远程分支中删除提交,提交并推送新的jar.我最近改用此方法,只是注意到它对存储库大小没有影响(它会不断增长):

Basically, the last commit always contains only the .jar files, I delete it, force push to delete the commit from the remote branch, commit and push the new jars. I have recently switched to this, only to notice it has no effect on repository size (it keeps growing):

git reset --hard HEAD~
git commit -m "Some message"
git push -f origin some-branch

我认为这应该与以前的方法相同.它不是.为什么?

I thought this should have been equal to the previous method. It is not. Why?

推荐答案

使用git push -f时,不再引用最后一次提交,但不会删除该提交.最终git会垃圾收集孤立的数据以节省一些空间.

When you use git push -f the last commit is no longer referenced, but is not deleted. Eventually git will garbage collect orphaned data to save some space.

如果您使用Bitbucket Cloud,则可以联系支持部门以运行git gc释放一些空间.

If you use Bitbucket Cloud, you can contact Support to run a git gc to free some space.

Bitbucket文档提供了减少存储库大小的建议: https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html

Bitbucket documentation provide advices to reduce repository size : https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html

这篇关于删除提交以减小存储库大小的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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