Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamokano/87f9708f616c42c6d45e104f3c510ffa to your computer and use it in GitHub Desktop.
Save williamokano/87f9708f616c42c6d45e104f3c510ffa to your computer and use it in GitHub Desktop.
finding a deleted file in a git repository
# If you don't remember the exact path/name, search the log for deleted files
git log --diff-filter=D --summary | grep delete
# Find the file you want to get from the ouput, and use the path
# Find the commits that involved that path
git log --all -- some/path/to/deleted.file
# Bring the file back to life to the current repo (sha commit of parent of commit that deleted)
g co shaofthecommitthatdeletedthefile^ -- some/path/to/deleted.file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment