alien
alien

Reputation: 859

How to find a file in a git repo that was lost

There was once a file in our repo that had some content we need to retrieve. There's too many logs to go one by one. So I was thinking we could run a command to list the files that were created and their commit hash. How can you do that?

Then I can just checkout that commit and see the file. Alternatively, if you know how to list what commits had the certain file, that would be even better. The file is foo.md let's say. Then I could checkout the last commit of that file.

Upvotes: 1

Views: 61

Answers (1)

KennetsuR
KennetsuR

Reputation: 788

  • there is built cmd in git
git ls-files -d, --deleted         show deleted files in the output
git log --diff-filter=D --summary --pretty=format:"%h" --stat

it prints

5d07713
 test2 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 test2

Upvotes: 2

Related Questions