0

I have a git bare repository named "master.git" where i regularly run "git gc --prune=now" at regular intervals.

I have another git bare repository named "slave.git" which is created with the --mirror option from "master.git". But i have stopped "git gc" and will not run, even automatically by turning off in the gitconfig.

Am keeping "slave.git" in sync with "master.git" by pushing with --force --mirror option from master.git -> slave.git

The master.git repository will get changes from developers and slave.git will NOT get any changes from developers and is like a read-only copy.

So the question is if master.git repository is GC'ed regularly and its changes are pushed with mirror option to slave.git, will slave.git repository require a "git gc" to run to keep it optimized OR since we are mirroring an already GC'ed repository slave.git won't require garbage collection?

AmericanUmlaut
  • 2,817
  • 2
  • 17
  • 27
Senthil A Kumar
  • 10,306
  • 15
  • 44
  • 55

2 Answers2

1

I have a git bare repository named "master.git" where i regularly run git gc --prune=now at regular intervals.

This is surely overkill. Do e.g. du -sh objects in the repo before and after your gc to see how much space you're saving. I'd recommend git gc --auto instead.

Am keeping "slave.git" in sync with "master.git" by pushing with --force --mirror option from master.git -> slave.git […] will slave.git repository require a "git gc" to run to keep it optimized OR since we are mirroring an already GC'ed repository slave.git won't require garbage collection?

When you push or fetch, new objects are sent across in a pack. git gc will coalesce packs when there get to be too many of them (50 now, it was raised from 20 in 2008), so eventually it'll get to be worth something.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • Thanks jthill, yes i do have a script that does check for the objects, whether they need packing and then does the gc. Sorry i wasn't elaborate. – Senthil A Kumar Dec 15 '16 at 10:58
0

The mirror aspect of git push --mirror means that the refs (branches and tags) are available under the same names and point to the same objects as the source. It does not mean that the underlying database is an exact mirror.

Yes, you still need to gc in the mirror destination because it accumulates garbage when old objects are abandoned. Such objects are not cleaned away by the push operation just because the objects are not present in the source anymore.

j6t
  • 9,150
  • 1
  • 15
  • 35