.git 文件夹将近 30GB

.git folder with almost 30GB

我在 .git 文件夹占用近 30GB 的服务器中遇到了这个问题。是否有任何命令(bitbucket)可以清除特定日期的数据?我不想在其中添加更多磁盘 space。

一个快速的解决方法是使用带有 git clone --depth=5 的浅层克隆。这将减少克隆回购的历史:

--depth <depth>

Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.

不过,您应该确定是什么占用了整个 30GB。

finding large objects in the repository. If you see something that was incorrectly committed and can be removed, e.g. large binary files that were committed by mistake, you can delete these with the BFG tool 开始。