找到git repo的大小

时间:2011-11-18 16:03:24

标签: git filesize

找到我的git存储库大小的简单方法是什么?我并不是说我的仓库的根目录上有du -h。我有很多被忽略的文件,因此大小与我的总回购大小不同。我基本上想知道在克隆我的回购时会传输多少数据。

8 个答案:

答案 0 :(得分:230)

  

UPDATE git 1.8.3引入了一种更有效的方法来获得粗略的大小:git count-objects -vH(请参阅@VonC的回答)

对于“完整尺寸”的不同想法,您可以使用:

git bundle create tmp.bundle --all
du -sh tmp.bundle

关闭(但不完全相同:)

git gc
du -sh .git/

对于后者,你也会计算:

  • config(遥控器,推送分支,设置(空格,合并,别名,用户) 细节等。)
  • stashes(另见Can I fetch a stash from a remote repo into a local branch?
  • rerere cache(可能相当可观)
  • reflogs
  • 备份(来自filter-branch,例如)和其他各种事物(中间的 从rebase,bisect等国家。)

答案 1 :(得分:211)

请注意,因为git 1.8.3 (April, 22d 2013)

  

git count-objects”了解了“--human-readable”又名“-H”选项,可在Ki / Mi / GiB中显示各种大号根据需要进行缩放。

可以与Jack Morrisonhis answer提及的-v选项结合使用。

git gc
git count-objects -vH

git gc非常重要,正如A-B-B answer提到的那样

Plus(仍然是git 1.8.3),输出更完整:

  

git count-objects -v”学会了报告对象库中剩余的临时包文件和其他垃圾

答案 2 :(得分:102)

git命令

git count-objects -v

将为您提供git存储库大小的良好估计。如果没有-v标志,它只会告诉您解压缩文件的大小。这个命令可能不在你的$ PATH中,你可能需要跟踪它(在Ubuntu上我发现它在/ usr / lib / git-core /中)。

来自Git man-page:

  

-v, - verbose

     

除了消耗的松散物体和磁盘空间的数量,              它会报告包装内物品的数量,包装数量,磁盘数量              这些包占用的空间,以及可以的对象数量              通过运行git prune-packed来删除。

您的输出将类似于以下内容:

count: 1910
size: 19764
in-pack: 41814
packs: 3
size-pack: 1066963
prune-packable: 1
garbage: 0

您正在寻找的行是size-pack。这是所有打包的提交对象的大小,或者是新克隆的存储库的最小可能大小。

答案 3 :(得分:3)

您可以在Accounts settings

中轻松找到每个存储库的大小

答案 4 :(得分:1)

如果使用git LFS,git count-objects不会计算二进制文件,只会计算指向它们的指针。

如果您的LFS文件由Artifactorys管理,则应使用REST API:

  • 从任何搜索引擎获取www.jfrog.com API
  • 查看获取存储摘要信息

答案 5 :(得分:1)

您可以使用git-sizer。在--verbose设置中,示例输出为(下)。寻找Total size of files行。

$ git-sizer --verbose
Processing blobs: 1652370
Processing trees: 3396199
Processing commits: 722647
Matching commits to trees: 722647
Processing annotated tags: 534
Processing references: 539
| Name                         | Value     | Level of concern               |
| ---------------------------- | --------- | ------------------------------ |
| Overall repository size      |           |                                |
| * Commits                    |           |                                |
|   * Count                    |   723 k   | *                              |
|   * Total size               |   525 MiB | **                             |
| * Trees                      |           |                                |
|   * Count                    |  3.40 M   | **                             |
|   * Total size               |  9.00 GiB | ****                           |
|   * Total tree entries       |   264 M   | *****                          |
| * Blobs                      |           |                                |
|   * Count                    |  1.65 M   | *                              |
|   * Total size               |  55.8 GiB | *****                          |
| * Annotated tags             |           |                                |
|   * Count                    |   534     |                                |
| * References                 |           |                                |
|   * Count                    |   539     |                                |
|                              |           |                                |
| Biggest objects              |           |                                |
| * Commits                    |           |                                |
|   * Maximum size         [1] |  72.7 KiB | *                              |
|   * Maximum parents      [2] |    66     | ******                         |
| * Trees                      |           |                                |
|   * Maximum entries      [3] |  1.68 k   | *                              |
| * Blobs                      |           |                                |
|   * Maximum size         [4] |  13.5 MiB | *                              |
|                              |           |                                |
| History structure            |           |                                |
| * Maximum history depth      |   136 k   |                                |
| * Maximum tag depth      [5] |     1     |                                |
|                              |           |                                |
| Biggest checkouts            |           |                                |
| * Number of directories  [6] |  4.38 k   | **                             |
| * Maximum path depth     [7] |    13     | *                              |
| * Maximum path length    [8] |   134 B   | *                              |
| * Number of files        [9] |  62.3 k   | *                              |
| * Total size of files    [9] |   747 MiB |                                |
| * Number of symlinks    [10] |    40     |                                |
| * Number of submodules       |     0     |                                |

[1]  91cc53b0c78596a73fa708cceb7313e7168bb146
[2]  2cde51fbd0f310c8a2c5f977e665c0ac3945b46d
[3]  4f86eed5893207aca2c2da86b35b38f2e1ec1fc8 (refs/heads/master:arch/arm/boot/dts)
[4]  a02b6794337286bc12c907c33d5d75537c240bd0 (refs/heads/master:drivers/gpu/drm/amd/include/asic_reg/vega10/NBIO/nbio_6_1_sh_mask.h)
[5]  5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c (refs/tags/v2.6.11)
[6]  1459754b9d9acc2ffac8525bed6691e15913c6e2 (589b754df3f37ca0a1f96fccde7f91c59266f38a^{tree})
[7]  78a269635e76ed927e17d7883f2d90313570fdbc (dae09011115133666e47c35673c0564b0a702db7^{tree})
[8]  ce5f2e31d3bdc1186041fdfd27a5ac96e728f2c5 (refs/heads/master^{tree})
[9]  532bdadc08402b7a72a4b45a2e02e5c710b7d626 (e9ef1fe312b533592e39cddc1327463c30b0ed8d^{tree})
[10] f29a5ea76884ac37e1197bef1941f62fda3f7b99 (f5308d1b83eba20e69df5e0926ba7257c8dd9074^{tree})

答案 6 :(得分:1)

认为,这会给您回购历史记录中所有文件的总列表:

git rev-list --objects --all | git cat-file --batch-check="%(objectsize) %(rest)" | cut -d" " -f1 | paste -s -d + - | bc

您可以将--all替换为树状的{HEADorigin/master等)以计算分支的大小。

答案 7 :(得分:0)

如果存储库位于github上,则可以使用开源android应用octodroid,该应用默认显示存储库的大致大小。 例如,使用mptcp存储库

size of multipath tcp repository on octodroid

size of the repository while cloning

免责声明:我没有创建八角形。