Skip to contentSkip to conversation

git repack with a --reference

DISCUSSION Jonathan Harker 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi - hope this isn't too noobish but I'm trying to get an existing git checkout to repack/prune/gc itself such that it would be like I had cloned it with --reference /path/to/local/repo (i.e. I've added /path/to/local/repo to .git/objects/info/alternatives, and I'd like it to reduce its objects from 200 MB to 5 MB). Is this

a. possible,

b. desirable, and

c. not insane?

Cheers,
Jonathan Harker
http://catalyst.net.nz/

#1 lore raw
Quoted 9 lines · Jonathan Harker

Hi - hope this isn't too noobish but I'm trying to get an existing git checkout to repack/prune/gc itself such that it would be like I had cloned it with --reference /path/to/local/repo (i.e. I've added /path/to/local/repo to .git/objects/info/alternatives, and I'd like it to reduce its objects from 200 MB to 5 MB). Is this

a. possible,
b. desirable, and
c. not insane?

I've done this in the past (using "git gc", but same difference I guess), and it worked as you'd hope, reducing .git to something very small.

I don't recall any real problems, but you might need to manually remove any pack ".keep" files first though (I seem to recall something like that, anyway).

-Miles

Signature · 2 lines
Friendship, n. A ship big enough to carry two in fair weather, but only one
in foul.
#2 lore raw
In reply to Jonathan Harker
Quoted 11 lines · Jonathan Harker

Hi - hope this isn't too noobish but I'm trying to get an existing git checkout to repack/prune/gc itself such that it would be like I had cloned it with --reference /path/to/local/repo (i.e. I've added /path/to/local/repo to .git/objects/info/alternatives, and I'd like it to reduce its objects from 200 MB to 5 MB). Is this

a. possible,

b. desirable, and

c. not insane?

yes,yes,yes.

The path written to .git/objects/info/alternates (also notice spelling of "alternates") should be the path to the objects directory, not to the toplevel repository.

i.e.

/path/to/local/repo.git/objects

It should work properly since git v1.6.2.3.

-brandon