Skip to content

Instantly share code, notes, and snippets.

@bgadrian
Created February 1, 2017 16:19
Show Gist options
  • Save bgadrian/84ae6795a59bfcd01263997d9f4859bf to your computer and use it in GitHub Desktop.
Save bgadrian/84ae6795a59bfcd01263997d9f4859bf to your computer and use it in GitHub Desktop.
Git corrupted data, lose objects, errors.
#Unfortunately you will lose any unpushed commits and stashed changes, however your working copy should remain intact.
cp -r . ../backupDontForget
rm -fr .git
git init
git remote add origin [your-git-remote-url]
git fetch
git reset --mixed origin/master
git branch --set-upstream-to=origin/master master
#commit and push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment