If you can't run git gc
yourself, you're going to have to trick it into running automatically. You won't have quite such full control over it then, but you should at least be able to get it to run.
git gc --auto
is run by several commands; the relevant one here is receive-pack, which is run on the remote to receive a pack as part of a push. gc --auto
only repacks when there are enough loose objects; the cutoff is determined by the config parameter gc.auto
, and defaults to 6700.
If you have access to the remote's gitconfig, you could set that cutoff to 1 temporarily. There should pretty definitely be at least 1 loose object in the repo, so that should cause gc --auto
to do its thing the next time you push.
If you don't have access to the remote's gitconfig, all I can think to do is artificially create a bunch of loose objects. You could do that by creating a branch, committing a bunch of tiny files (with different content) to it, pushing the branch to the remote, then deleting the branch from the remote. (Important to vary the content, or they'll just use the same blobs.) Rinse and repeat.