1

I have a huge git repository and I want to reduce the size. To achieve that, I want to delete a folder, which exists many times in different subdirectories with the same name.

The git repository has the following folder structure:

- ID1
   - Graphs
- ID2
   - Graphs

I want to delete all Graphs folders, because they are huge. I ran the java -jar ~/Downloads/bfg-1.13.0.jar --delete-folders Graphs --no-blob-protection ~/path/to/Repo with the following output:

Using repo : ~/path/to/Repo/.git

Found 0 objects to protect
Found 3 tag-pointing refs : refs/tags/VERSION1.4, refs/tags/VERSION1.5, refs/tags/VERSION3.1
Found 5 commit-pointing refs : HEAD, refs/heads/master, refs/remotes/origin/HEAD, ...

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 284 commits
Cleaning commits:       100% (284/284)
Cleaning commits completed in 268 ms.

Updating 3 Refs
---------------

    Ref                           Before     After
    -------------------------------------------------
    refs/heads/master           | 7f5ba511 | fcd2600c
    refs/remotes/origin/develop | c30fa798 | 7e345ac0
    refs/remotes/origin/master  | 7f5ba511 | fcd2600c

Updating references:    100% (3/3)
...Ref update completed in 20 ms.

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

    Earliest                                              Latest
    |                                                          |
    ...DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDm

    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 | 3fba1762 | 7a24f280
    Last dirty commit     | 0ea27985 | 1cc26472


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

    ~/path/to/Repo.bfg-report/2019-04-03/16-35-48

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive

Then I followed the instruction and ran git reflog expire --expire=now --all && git gc --prune=now --aggressive. That took at least 5h to complete. Output (I tried to translate):

Object count: 11191, Fertig.
Counting objects: 100% (11191/11191), Fertig.
Delta Compression is using up to 12 threads.
compress objects: 100% (11115/11115), Fertig.
write objects: 100% (11191/11191), Fertig.
Total 11191 (Delta 1866), Re-used 5522 (Delta 0)

Now, after it is completed the size of the repository is only slightly smaller.

Looking in the checked out directory, the size is only <50MB. But the size of the .git folder is >19GB. When looking through the history, it seems that the Graphs folders are gone.

I do not understand, why the repository size is still that huge, but the folders are actually gone in the commit history.

caldicot
  • 195
  • 2
  • 15
  • Having the same issue, I run bfg with --no-blob-protection, it says it's deleting the files I ask it to delete, I expire and gc the repository, but if I look at the history or rerun the same bfg command, it's still there. – Quartz Feb 11 '20 at 21:07

0 Answers0