Created
November 18, 2010 03:27
-
-
Save andrewsardone/704579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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