Skip to content

Instantly share code, notes, and snippets.

@andrewsardone
Created November 18, 2010 03:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsardone/704579 to your computer and use it in GitHub Desktop.
Save andrewsardone/704579 to your computer and use it in GitHub Desktop.
# need to fix a corrupted repo because I have a local branch I need to recover
# first, backup the corrupted git repo
# get a fresh clone
$ git clone git://mydomain.local/awesomerepo.git; cd awesomerepo
$ mv .git/objects/pack/*.pack /tmp/.
$ git unpack-objects < /tmp/*.pack # unpack all the git objects.
# you need to move the pack file out of the
# git repo. See git-unpack-objects's man page:
# "Objects that already exist in the repository
# will not be unpacked from the pack-file. Therefore,
# nothing will be unpacked if you use this command
# on a pack-file that exists within the target
# repository."
# locate the corrupt object in the clean, cloned repo and copy it into the corrupt repo
$ cp -f .git/objects/cc/6df31dfbc5231441c4b815975d576420517d8a ../awesomerepo_corrupt/.git/objects/cc/.
# hat tip to frogonwheels and rohanpm on #git on irc.freenode.net for helping me out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment