Skip to content

Instantly share code, notes, and snippets.

@nahurst
Created July 29, 2012 16:41
Show Gist options
  • Save nahurst/3200127 to your computer and use it in GitHub Desktop.
Save nahurst/3200127 to your computer and use it in GitHub Desktop.
Recovering from corrupted Git
Get the previous commit hash from the last line of .git/logs/HEAD
Replace .git/refs/heads/yourbranch with it
"git status" should now work. Note the files changed (you will copy them later)
Push this repo elsewhere (a different branch on origin)
Remove the .git directory
Pull that repo back out to a different directory
Copy over the noted files to that directory
Commit them
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment