简体   繁体   English

BFG Repo Cleaner未按预期工作

[英]BFG Repo Cleaner is not working as expected

I am trying to reduce the size of a largish repo (~3.4 G) and bfg-repo-cleaner seemed like a perfect tool to to reduce the size of it. 我正在努力减小大型仓库(~3.4 G)的尺寸,而bfg-repo-cleaner似乎是减小它尺寸的完美工具。

I ran the tool as described in the docs but am only seeing minor reductions in the size of the repo. 我按照文档中的描述运行了该工具,但我只看到了repo大小的轻微减少。 What is particularly surprising is that some (but not all) of the blogs that the tool has said it removed (deleted-files.txt) are still very much in the repository. 特别令人惊讶的是,该工具已删除的一些(但不是全部)博客(deleted-files.txt)仍在存储库中。 I really don't want to start messing with git filter-branch so any help would be appreciated. 我真的不想开始搞乱git filter-branch所以任何帮助都会受到赞赏。

I intentionally went with the aggressive --no-blob-protection option to maximize the effect. 我故意使用积极的--no-blob-protection选项来最大化效果。 I've included the commands I ran with the truncated output. 我已经包含了我用截断输出运行的命令。

git count-objects -vH git count-objects -vH

count: 0
size: 0 bytes
in-pack: 1616184
packs: 1
size-pack: 3.38 GiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

du -rh -d 0 du -rh -d 0

3.4G    .

java -jar ~/Downloads/bfg-1.12.12.jar --strip-blobs-bigger-than 2M --no-blob-protection ./ java -jar~ / Downloads / bfg-1.12.12.jar --strip-blobs-greater-than 2M --no-blob-protection ./

Scanning packfile for large blobs: 1616184
Scanning packfile for large blobs completed in 33,465 ms.
Found 242 blob ids for large blobs - biggest=497179278 smallest=2098032
Total size (unpacked)=3534794122
Found 0 objects to protect
Found 4965 tag-pointing refs : ...
Found 8519 commit-pointing refs :  ...

Protected commits
-----------------

You're not protecting any commits, which means the BFG will modify the contents of even *current* commits.

This isn't recommended - ideally, if your current commits are dirty, you should fix up your working copy and commit that, check that your build still works, and only then run the BFG to clean up your history.

Cleaning
--------

Found 110364 commits
Cleaning commits:       100% (110364/110364)
Cleaning commits completed in 345,977 ms.

Updating 13483 Refs
-------------------

Ref                                                                                                                  Before     After
----------------------------------------------------------------------------------------------------------------------------------------
...

Updating references:    100% (13483/13483)
...Ref update completed in 15,354 ms.

Commit Tree-Dirt History
------------------------

Earliest                                              Latest
|                                                          |
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

D = dirty commits (file tree fixed)
m = modified commits (commit message or parents changed)
. = clean commits (no changes to file tree)

                        Before     After
-------------------------------------------
First modified commit | 757f8383 | c11fc923
Last dirty commit     | e28d047b | 92b88b05

Deleted files
-------------
...

In total, 418853 object ids were changed. Full details are logged here:

..bfg-report/2016-04-18/10-24-49

git count-objects -vH git count-objects -vH

count: 419093
size: 1.62 GiB
in-pack: 1616184
packs: 1
size-pack: 3.38 GiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

du -rh -d 0 du -rh -d 0

5.1G    .

git reflog expire --expire=now --all && git gc --prune=now --aggressive git reflog expire --expire = now --all && git gc --prune = now --aggressive

Counting objects: 1905870, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1786570/1786570), done.
Writing objects: 100% (1905870/1905870), done.
Total 1905870 (delta 1274991), reused 482300 (delta 0)
Removing duplicate objects: 100% (256/256), done.
Checking connectivity: 1905870, done.

git count-objects -vH git count-objects -vH

count: 0
size: 0 bytes
in-pack: 1905870
packs: 1
size-pack: 3.03 GiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

head ..bfg-report/2016-04-18/10-24-49/deleted-files.txt head ..bfg-report / 2016-04-18 / 10-24-49 / deleted-files.txt

8afa72875d3013620bb122916bd1ec33a066cbf2 1075353 file_name1.gpx
7656f6464c67f92c48cdbb03ec5a81067c636238 1644202 file_name2.csv
ab68fb197d4479b3b6dec6e85bd5cbaf433a87c5 773236 file_name3.ttf
86c9c0b55ff99c3789bb3ed17daf51bebacba1cb 870631 file_name4@2x.png
70c928943feab0a3a1f97b4f752e9dbc1d8f37fa 950305 file_name5@2x.png
3862d0da43f5902c75e86ff0dd925d8cca601de3 779356 file_name6@2x.png
6effce4b245961cb46e2cf3f4d05bd6c8c182760 908017 file_name7@2x.png
1866b1053dd48fc4d0677f03feb4baf2f67b567c 1353732 file_name8.gif
f0d984f00678504fe073110bb6553049e9678755 1350785 file_name9.gif
af877d286b12b9f79560a938375abe04a15ff405 3214192 file_name10.gif

git cat-file -s 8afa72875d3013620bb122916bd1ec33a066cbf2 git cat-file -s 8afa72875d3013620bb122916bd1ec33a066cbf2

1075353

I've figured out the problem. 我已经找到了问题所在。 We had a lot of old branches that still pointed to trees with large blobs. 我们有很多老枝仍然指向有大块的树木。 Deleting these and rerunning bfg gave me a multi gigabyte reduction. 删除这些并重新运行bfg让我减少了几千兆字节。

I had thought that the --no-blob-protection flag would have addressed this state. 我原以为--no-blob-protection标志会解决这个问题。

I found that rerunning the bfg with the same command arguments multiple times kept having it find more commits to clean. 我发现用同样的命令参数重复运行bfg多次让它找到更多的提交要清理。 Eventually it said 最终它说

BFG aborting: No refs to update - no dirty commits found??

At that point, reflog expire and gc reduced the pack size. 此时, reflog expire并且gc减小了包大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM