Once upon a time, there was a file in my project that I would now like to be able to get.
The problem is: I have no idea of when have I deleted it and on which path it was.
How can I locate the commits of this file when it existed?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you do not know the exact path you may use
If you know the path the file was at, you can do this:
This should show a list of commits in all branches which touched that file. Then, you can find the version of the file you want, and display it with…
Or restore it into your working copy with:
git checkout <SHA>^ -- <path-to-file>Note the caret symbol (
^), which gets the checkout prior to the one identified, because at the moment of<SHA>commit the file is deleted, we need to look at the previous commit to get the deleted file’s contents