Removing a commit in git rebase -i does not reduce the size of the .git folder

I have a git repository where the .git folder is 7 MB . Then I added and committed the .exe file with 16 MB , and then:

 git gc --aggressive && git prune 

After the above .git folder is now 23 MB .

Next, I did git rebase -i and selected drop:

enter image description here

on the commit ( c8185ff ) that provided the 16 megabyte file, I completed the reboot and ran again:

 git gc --aggressive && git prune 

Now that I am measuring the .git folder, it is still 23 MB .

If you run git rebase above, do not delete the commit completely from the history - as if the file had never been entered - and therefore return the .git folder to 7 MB ?

I also tried to make a new repository clone and the size is still 23 MB . I assume that the reflog will be cleared when a new clone is created.

+5
source share
1 answer

By default, git gc only removes free objects older than 2 weeks.

To force cropping all objects, use --prune=all :

 git -c gc.reflogExpire=now gc --prune=all 

But if the object is still accessible through any link (for example, deleted, for example, origin/master or reflog), it will not be truncated.

That is why we should install gc.reflogExpire configuration now .

(For git prune [optional after gc], --expire )

+2
source

Source: https://habr.com/ru/post/1269223/


All Articles