Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# 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 for helping me out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.