0

I have git repository with size 38GB and rising.

Is there a way to have local "thin" repository which will contain only current state of remote repository without any history?

I tried git clone --depth=1 but this only downloads repository with last change and not forcing repository to have always minimal possible size.

BPS
  • 1,133
  • 1
  • 17
  • 38
  • Just for curiosity, why your repository size is 38GB do you use .gitignore ? – aydinugur Jul 02 '18 at 06:46
  • 1
    @aydinugur it's very old project, with very large number of text files, there's no binaries in it. Beside this, programmers tend to do like 3-4 commits per every 10 min :P so history swells very fast. – BPS Jul 02 '18 at 06:54
  • 1
    Try `git gc`. The repository may have too many loose objects. – ElpieKay Jul 02 '18 at 08:00
  • Possible duplicate of [Reduce git repository size](https://stackoverflow.com/questions/2116778/reduce-git-repository-size) – phd Jul 02 '18 at 08:42
  • You might want to increase the frequency of automatic `git gc` of loose objects. The default value (not documented anywhere) for `gc.auto` is 6700. Don't set it super-tiny right away—auto-packing of loose objects too soon will get you more packs but each one will be less efficient than a larger pack, and as soon as you have 50 packs you'll trigger a repack, which is slow. It will take some experimentation to find the right value to make Git behave best. – torek Jul 02 '18 at 15:52

1 Answers1

0

Archive the current repo at a major release, say 1.0 -> 2.0. Create a new repo fresh with just the project files, and mark the old one as read only. This way you still have the history in the archive, but start with a fresh small repo.

This may not work well if you have to support multiple versions (clients still on previous versions, which patches need to be rolled into the current version).

Paul Reedy
  • 360
  • 3
  • 10