garbage collection - Git - why does the number of objects differ between my two Git clones? -


i have 2 local repositories cloned same remote. pulled changes both local repositories branches but number of objects shown when calling git gc example (or git pull) differs...

does mean 2 repositories not in-sync?

the number of 'in-pack' objects shown git count-objects -v:

count: 0 size: 0 in-pack: <this number here> packs: 1 size-pack: <a size> prune-packable: 0 garbage: 0 size-garbage: 0 

or alternatively git gc

counting objects: <here>, done. delta compression using 6 threads. compressing objects: 100% (yyyy/yyyy), done. writing objects: 100% (<here>/<here>), done. total <here> (delta xxxx), reused <here> (delta zzzz) 

shouldn't number of objects same 2 local repositories? (since both up-to-date?)

first, should check references have running git for-each-ref (or similar) in each repository. references, including things in stash, hold on objects appear in 1 repository.

that aside, "active" git repository (by "active" mean 1 in edit , git add , git commit , git rebase, git reset, git stash, , on) accumulates number—potentially large number—of "deleted, not yet expired" commits. (it accumulates deleted , expired commits too, mentioned git gc above, , removes these, no longer contribute object count.)

if expire reflogs , prune (note, removing safety belts , harnesses, tossing high-wire balance pole aside, ditching lifeboats, , opening outer airlocks1 ... i.e., don't on whim):

git reflog expire --expire=now --expire-unreachable=now --all git prune --expire=now 

and run git gc, should minimum number of objects. (if both repositories active might have on both.)


1apparently, you're doing on high wire attached car being driven on boat sailing on ocean inside space habitat. wow. :-)


Comments