Skip to content

Instantly share code, notes, and snippets.

@kerembaydogan
Created February 27, 2020 18:23
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 kerembaydogan/a5eda9f24f90b6876a8a3fe7270090ac to your computer and use it in GitHub Desktop.
Save kerembaydogan/a5eda9f24f90b6876a8a3fe7270090ac to your computer and use it in GitHub Desktop.
Git Bring Back Deleted Files
## run this line
## find the file you are searching for
## note output ex: 'delete mode 100755 folder1/folder2/deletedFile.xml'
git log --diff-filter=D --summary | grep delete
## run this line
## note output ex: 'a0f533730f4255b0c8f36d9f2594b4aed5e772ce'
git rev-list -n 1 HEAD -- folder1/folder2/deletedFile.xml
## run this line using output of the previous command
## DO NOT DELETE '~1' CHARACTERS
git checkout a0f533730f4255b0c8f36d9f2594b4aed5e772ce~1 -- folder1/folder2/deletedFile.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment