3

I have a bare git repository with some loose objects. How do I pack all loose obects into a single, new pack, without changing other packs?

3 Answers 3

3

git pack-objects < object_list.txt

where object_list.txt has a list of object hashes, delimited by '\n'.

git-pack-objects

1
  • Thank you for the suggestion, it was useful for me to solve the problem. I can't accept, because it doesn't solve the problem end-to-end.
    – pts
    Commented Sep 9, 2013 at 22:20
2

I could come up with:

$ git prune-packed
$ find objects/?? -type f | perl -pe 's@^objects/(..)/@$1@' |
  git pack-objects objects/pack/pack
$ git prune-packed

Is there anything simpler?

0

Warning, when using git prune-packed.

Before Git 2.22 (Q1 2019), "git prune-packed" did not notice and complain against excess arguments given from the command line, which now it does.

See commit 9b0bd87 (11 Feb 2019) by Ramsay Jones (jeffhostetler).
(Merged by Junio C Hamano -- gitster -- in commit ebf846c, 07 Mar 2019)

It will now display "too many arguments" if any argument is passed to git prune-packed.

1
  • 1
    This is nice to know, but it doesn't answer the question.
    – pts
    Commented Mar 11, 2019 at 14:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.