Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a git repository that i have packed with git repack -a -d, this repacked all the objects into one big file. This saves space. However I want to undo this, and turn that one big pack file into all the little object files.

The reason I want to do this is to backup the git repository to a remote server. I did a backup (before repacking). Installing git on the remote server is nontrivial, so I was going to use rsync to copy the files. However rsync is not this clever and will basically want to copy things again. If I can 'unpack' this repository, it might make it quicker to copy.

like image 711
Amandasaurus Avatar asked Jan 12 '10 21:01

Amandasaurus


1 Answers

git-unpack-objects will unpack the objects, but only inside a repo that doesn't contain the pack:

Make a new, empty repo:

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

Write the objects in:

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

Pull the necessary branches/tags in:

git pull ../old-repo

Or, if you're adventurous, you could attempt to use the objects directory in new-repo as a replacement for the old one.

like image 155
Josh Lee Avatar answered Oct 08 '22 17:10

Josh Lee