如何清理远程git仓库中的垃圾 [英] How to cleanup garbage in remote git repo
问题描述
这个效果很好,但是,我注意到在运行git count之后,有大量的空间坐在垃圾箱中。所以我跑了一个简单的git gc。但是,这并没有清理垃圾。
经过一番挖掘,我发现了以下命令:
git - c gc.reflogExpire = 0 -c gc.reflogExpireUnreachable = 0 -c gc.rereresolved = 0 \
-c gc.rerereresolved = 0 -c gc.pruneExpire = now gc$ @
运行此操作会导致垃圾被清理 本地 。但是,我仍然有远程回购的问题。我现在是否需要让Bitbucket在远程仓库中运行此命令,或者有办法将此更改推送到仓库?
如果有其他人遇到这种情况,答案就是肯定的。
Bitbucket支持运行以下内容:
bash-4.1 $ git reflog expire --expire =1小时--all
bash-4.1 $ git reflog expire --expire -reachable =1小时--all
bash-4.1 $ git prune --expire =1小时-v
bash-4.1 $ git gc --aggressive --prune =1小时
之前和之后的远程回购大小从2GB减少到1GB以下。
I recently ran into a size limit with my Bitbucket repo. I followed the countless other questions answering how to clean up your git repo and ended up using BFG to remove some bad commits.
This worked great, however, I noticed that after running a git count, there was a large amount of space sitting in garbage. So I ran a simple git gc. However, that did nothing to clean up the garbage.
After some digging I found the following command:
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 \
-c gc.rerereunresolved=0 -c gc.pruneExpire=now gc "$@"
Running this led to the garbage being cleaned up locally. However, I still have the issue of the remote repo. Do I now need to get Bitbucket to run this command on my remote repo, or is there a way to push this change to the repository?
If anyone else is experiencing this, the answer turned out to be yes.
Bitbucket support ran the following:
bash-4.1$ git reflog expire --expire="1 hour" --all
bash-4.1$ git reflog expire --expire-unreachable="1 hour" --all
bash-4.1$ git prune --expire="1 hour" -v
bash-4.1$ git gc --aggressive --prune="1 hour"
The before and after reduced the remote repo size from over 2GB, to under 1GB.
这篇关于如何清理远程git仓库中的垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!