Skip to content

Instantly share code, notes, and snippets.

@lhuria94
Forked from msankhala/git-restore-file.sh
Created September 22, 2017 06:08
Show Gist options
  • Save lhuria94/d6f67b0d6daf18c65ce0dee632c984e0 to your computer and use it in GitHub Desktop.
Save lhuria94/d6f67b0d6daf18c65ce0dee632c984e0 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