Skip to content

Instantly share code, notes, and snippets.

@zfael
Forked from infusion/git-restore-file.sh
Created July 12, 2018 11:57
Show Gist options
  • Save zfael/12c2fa79052ff8e1b382cca2c54356c0 to your computer and use it in GitHub Desktop.
Save zfael/12c2fa79052ff8e1b382cca2c54356c0 to your computer and use it in GitHub Desktop.
Find and restore a deleted file in a Git
# Find last commit for the deleted file
git rev-list -n 1 HEAD -- $path
# Checkout the commit before the the delete happened
git checkout $commit^ -- $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment