I cloned a project from github with git clone --mirror. That left me with a repository with a packed-refs file, a .pack and an .idx file.
Yet another answer to your question 1:
I assume you already used a loop like this to use git unpack-objects:
mkdir CLONE mv .git/objects/pack/* CLONE/ for pack in CLONE/*.pack; do git unpack-objects < $pack done rm -rf CLONE/
which unpacks all objects, but leaves the packed branch heads in the file .git/packed-refs
Thanks to Clee's answer, which I reused here, I found that the following commands will be needed to unpack the branch heads, and clean up:
( IFS=$'\n'; # set the input field separator to new line for f in $(git show-ref --heads); do ref_hash="$(echo $f | cut -c1-40)" ref_label="$(echo $f | cut -c42-)" echo " unpack: $ref_hash $ref_label" echo "$ref_hash" > ".git/$ref_label"; sed -i "s~^${ref_hash} ${ref_label}\$~~" .git/packed-refs sed -i '/^$/d' .git/packed-refs done rm .git/info/refs rm .git/objects/info/packs )
Note the difference to Clee's answer:
A) the packed refs are removed from the .git/packed-refs file, and
B) the files .git/info/refs and .git/objects/info/packs are deleted.
I admit that it might not be a good idea to delete files just like that in the .git folder, however this is what I needed to do in order to do a clean unpack.
Question 2 is still not answered though.