Skip to content

Instantly share code, notes, and snippets.

@joakin
Last active May 21, 2024 17:37
Show Gist options
  • Save joakin/67f5afdd083ccfb8fecd to your computer and use it in GitHub Desktop.
Save joakin/67f5afdd083ccfb8fecd 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)
git checkout shaofthecommitthatdeletedthefile^ -- some/path/to/deleted.file
@monsilaro
Copy link

monsilaro commented Mar 22, 2023

nice thanks

@Eben-Hafkamp
Copy link

Cheers!

@kevineleven
Copy link

Awesome, thank you.

@shaunsim15
Copy link

2nd command was helpful for me, thanks!

@TheVonyo
Copy link

TheVonyo commented Aug 1, 2023

so nice !

@Pascal1515
Copy link

Thanks!!!

@bryanwhiting
Copy link

beautiful

@simxn1
Copy link

simxn1 commented Oct 10, 2023

Thanks!

@djoble-koutouan-shift
Copy link

🚀

@andifreed
Copy link

love the script name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment