Skip to content

Instantly share code, notes, and snippets.

@Sam-Gram
Last active May 2, 2018 17:55
Show Gist options
  • Save Sam-Gram/fe9df19e6ba1779cedbe824fd401992a to your computer and use it in GitHub Desktop.
Save Sam-Gram/fe9df19e6ba1779cedbe824fd401992a to your computer and use it in GitHub Desktop.
How I eventually fixed a corrupted git
# All commands start in project root
# Get back corrupted objects
git fetch -p
git unpack-objects < <new clone of remote>/.git/objects/pack/pack-<hash>.pack
#.get rid of empty files if git fsck isn't working or just in general
cd .git; find . -type f -empty -delete -print
# Find problems (anything other than dangling commit/object is a problem)
git fsck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment