Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Garbage collection doesnt seem to fully work

Tags:

I'm a little confused as how to completely clean out my garbage...

git count-objects -v -H

warning: garbage found: ./objects/pack/gc_7174754666377259454.idx_tmp
warning: garbage found: ./objects/pack/gc_7174754666377259454.pack_tmp
warning: garbage found: ./objects/pack/pack-f5b13f50fe2e4d773028c51f547822e6f2fe720b.bitmap
count: 0
size: 0 bytes
in-pack: 32986
packs: 1
size-pack: 44.14 MiB
prune-packable: 0
garbage: 3
size-garbage: 41.20 MiB

So that implies to me I have 41 megs of garbage in my repo?

git gc --prune=now --aggressive

Counting objects: 32986, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (31610/31610), done.
Writing objects: 100% (32986/32986), done.
Total 32986 (delta 23902), reused 9080 (delta 0)

And when I run count objects again i still have the same output with

    size-garbage: 41.20 MiB

Do I just manually delete the garbage files? At least one is quite plump at the very least.

12/02/2014  02:06 PM                 0 gc_7174754666377259454.idx_tmp
12/02/2014  02:06 PM        43,195,455 gc_7174754666377259454.pack_tmp
               2 File(s)     43,195,455 bytes
               0 Dir(s)  502,905,999,360 bytes free
like image 975
Jeef Avatar asked Dec 02 '14 19:12

Jeef


People also ask

How would you force git to trigger garbage collection?

The easiest option would be to use a scheduled task in windows or a cron job in Unix to run git gc periodically. This way you don't even need to think about it.

Does git gc prune?

git gc is a parent command and git prune is a child. git gc will internally trigger git prune . git prune is used to remove Git objects that have been deemed inaccessible by the git gc configuration.

When should we not run git gc?

Running git gc manually should only be needed when adding objects to a repository without regularly running such porcelain commands, to do a one-off repository optimization, or e.g. to clean up a suboptimal mass-import.

Does git gc remove Stash?

git stash clear It will remove all the stashed changes.


1 Answers

C:\Users\VonC\prog\git\git>git log -Ssize-garbage|more

This show the size-garbage output has been introduced in commit 1a20dd4 by Nguyễn Thái Ngọc Duy (pclouds) for git 1.8.3 (May 2013)

size-garbage: disk space consumed by garbage files, in KiB

count-objects: report how much disk space taken by garbage files

Also issue warnings on loose garbages instead of errors as a result of using report_garbage() function in count_objects()

This garbage cleaning tip section mentions:

To bring the repo size down the bare minimum, you need both the following commands (neither command by itself does the whole job).
Also Note the lowercase "a" on the "repack", which says you want to blindly discard unreachable objects instead of keeping them as loose objects.

git repack -adf     # kills in-pack garbage
git prune           # kills loose garbage

So try again the git count-objects -v -H after applying both commands.


Looking at the git repack man page, jthill adds in the comments:

I prefer the big-A option:

"Same as -a, unless -d is used.
Then any unreachable objects in a previous pack become loose, unpacked objects, instead of being left in the old pack."

Linus Torvalds argues that -f like gc's --aggressive is much overused -- so much so he suggested yanking the documentation for it.
(in 2007)
(-f is for --no-reuse-delta)

That means a more efficient combination might be:

git repack -Ad      # kills in-pack garbage
git prune           # kills loose garbage
like image 194
VonC Avatar answered Nov 03 '22 10:11

VonC