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