I have found this the most reliable way to recover from a corrupt git repository. I have had a lot of them lately, there might be a regression in btrfs in Ubuntu's Linux 3.8.0-33 (!).
- Create a clone of a known good repository.
- Add the clone as an object alternate to the broken repository.
- Do a
git-repack -a -dto lift the external objects into repo-local packs.
- Remove the clone
$ cd /tmp/ $ git clone good-host:/path/to/good-repo $ cd /home/user/broken-repo $ echo /tmp/good-repo/.git/objects/ > .git/objects/info/alternates $ git repack -a -d $ rm -rf /tmp/good-repo
... and push early, push often.