删除git克隆的git缓存

ezykj2lf  于 2023-06-04  发布在  Git
关注(0)|答案(1)|浏览(232)

我正在尝试克隆一个Git仓库,由于有很多分支,它的大小超过了1.5 GB。所以克隆被反复终止。全部对象为:

remote: Enumerating objects: 75566, done.
 remote: Counting objects: 100% (75566/75566), done.
 remote: Compressing objects: 100% (42818/42818), done.
 Receiving objects:   3% (2267/75566), 1.91 MiB | 297.00 KiB/s

所以我删除了大部分没有用的旧分支。所以它减少了尺寸:

remote: Enumerating objects: 3826, done.
remote: Counting objects: 100% (3826/3826), done.
remote: Compressing objects: 100% (392/392), done.
Receiving objects:   4% (3703/75566), 1.99 MiB | 280.00 KiB/s

你可以看到计数对象已经减少,但它仍然接收对象是75566。为什么会这样呢?如果是由于缓存,那么我如何才能清除它。
另外请注意,git rm -r --cached .不工作,因为我在任何项目之外克隆,并且没有.git文件夹
谢谢你

pxy2qtax

pxy2qtax1#

您可以使用--depth限制获取的对象数量(返回到获取的历史记录中的提交计数)

git clone --depth=1 ...

自**Git 2.11(Q4 2016)**git clone允许根据提交时间限制

git clone --shallow-since=<date>:
Create a shallow clone with a history after the specified time.

日期格式是git log支持的格式之一
有关何时添加此功能的详细信息,请参阅https://stackoverflow.com/a/39994584/468252

相关问题