Git - How to undo "git repack -ad"?

I have a git repository that I packed using git repack -a -d, which repackaged all the objects into one big file. This saves space. However, I want to undo this and turn this large package file into all small object files.

The reason I want to do this is to back up the git repository to a remote server. I made a backup (before repackaging). Installing git on a remote server is not trivial, so I was going to use rsyncto copy files. However, rsync is not so smart and basically wants to copy things again. If I can unzip this repository, it can speed up its copying.

+3
source share
3 answers

git-unpack-objects will unpack objects, but only inside a repo that does not contain a package:

Make a new, empty repo:

mkdir new-repo; cd new-repo; git init

Write the objects to:

git unpack-objects < ../old-repo/.git/objects/pack/pack-XXX.pack

Pull the necessary branches / tags to:

git pull ../old-repo

Or, if you are adventurous, you can try to use the object directory new-repoas a replacement for the old one.

+5
source

In fact, git-unpack-objects will work fine if you first rename or move the package file. It is intended to add an incoming package to the repository, adding all objects that do not yet exist. Just move the package file to the file name where git cannot find it, will make all its objects irreplaceable.

Basically:

mv .git/objects/pack .git/objects/pack.old
for i in .git/objects/pack.old/pack-*.pack; do
    git-unpack-objects < $i && rm $i ${i%pack}idx
done
rmdir .git/objects/pack.old

, , ( - ), Linus , ( rsync), , .

- ( ), .keep ( $i pack-*.pack, touch ${i%pack}keep). "", .

rsync "" , , , .keep shunk.

- git-bundle , .

+4

fast-export | fast-import

into a new repo. Most likely, no packaging will be launched. Otherwise, you can configure the package ( man git config, search for the package. *)

+1
source

Source: https://habr.com/ru/post/1728231/


All Articles