1

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?

  • List all files created for every commit in a repo.
  • Include the commit hash and file name.

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.

1 Answer 1

2
  • 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 
Sign up to request clarification or add additional context in comments.

2 Comments

This doesn't list all historically deleted files... My file was deleted at some point in the history, I don't know where.
@alien which cmd did you type in, git rm or just rm -r ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.