Skip to content

Instantly share code, notes, and snippets.

@afirth
Created August 13, 2020 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afirth/fb3b4dcd3ce1db9adc58993ff09cd02d to your computer and use it in GitHub Desktop.
Save afirth/fb3b4dcd3ce1db9adc58993ff09cd02d to your computer and use it in GitHub Desktop.
recover staged or reset files in git (ran git add but somehow discarded without committing)
export UNIQUE_CODE=sops_version
#from https://stackoverflow.com/a/14988152/13484536
for b in $(git fsck --lost-found | grep blob | awk '{print $3}'); do git cat-file -p $b | grep -q ${UNIQUE_CODE} && echo $b && git cat-file -p $b && echo; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment