13

I have a git working directory and have added to .git/objects/info/alternates so that this working directory does not need to store duplicate data that's already in another working directory on my machine. (This is what git clone --reference=DIRECTORY does). However, duplicate objects already stored in the working directory aren't deleted from my .git/ directory. This means the .git/ directory stays large.

How do I get rid of the duplicate objects so the .git/ directory is smaller?

Russell Silva
  • 2,772
  • 3
  • 26
  • 36

1 Answers1

11
git repack -adl

The -l option in particular omits objects that are borrowed from an alternate. See git help repack and git help pack-objects.

Russell Silva
  • 2,772
  • 3
  • 26
  • 36
  • Use [`-f` to not reuse deltas for optimal packs](https://manned.org/git-repack#:~:text=%2Df%0A%20%20%20%20%20%20%20%20%20%20%20Pass%20the%20%2D%2Dno%2Dreuse%2Ddelta) – Tom Hale Aug 11 '23 at 13:50