4

I have a repo with a big size .git folder (around 350mb) and I want to reduce it, because every time someone made a clone (even using the --single-branch flag) it lasts more than 3 minutes in pulling all the data.

After using du -h | sort -h I found the culprit and deleted it (it was a sql dump file at app/db.dump):

# Some files skipped
...
30M     ./public
30M     ./public/assets
338M    ./app
354M    ./.git
354M    ./.git/objects
354M    ./.git/objects/pack
729M    .

Now I'm trying to delete that big file that someone pushed by mistake from all the commits on the repo, to reduce its size. But I haven't yet succeeded.

I've already tried with the following commands but they are not working for me, the .git folder still preserves it size:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch app/db.dump" HEAD
git reflog expire --expire=now --all
git gc --prune=now --aggressive

I'm using git version 2.26.2.

Hope someone can shed me some light on this. Thank you!


EDIT:

Thanks! @Donat and @Tom, the problem was that I tried to reflog and prune without previously making a commit to remove the big file. This was stated after running bfg.jar, which gave me this clue in its output.

After doing a commit to remove the big file, I re-ran bfg.jar and the .git folder's size was finally shrunk

1 Answers1

0

Have a look at the code below. In effect your intention is to remove that file from every single commit where it may be referenced..

git filter-branch --force --index-filter \
  "git rm --cached --ignore-unmatch PATH-TO-BIG FILE" \
  --prune-empty --tag-name-filter cat -- --all
git push --force --verbose --dry-run
git push --force
Konrad
  • 17,740
  • 16
  • 106
  • 167