Paul Beckingham
Paul Beckingham

Reputation: 14895

Listing file names from an old commit

I have deleted several files from the repository a long time ago. Now years later I want to look at them. If I know the names of one of those files, I can look at the history for one of them using:

git log -- path/to/file

If I want to see a version of that file from an old commit, I use this:

git show COMMIT:path/to/file

But all of this assumes I know the path/to/file, which I don't. Is there a way to list all the files that existed at the time, from a given COMMIT?

I realize I can repeatedly do this until I find it:

git checkout -- COMMIT

But a complete file list from an old COMMIT would be ideal. Does such a capability exist? Given the comprehensiveness of git, I'll bet there is, but I surely don't know it.

Upvotes: 3

Views: 72

Answers (2)

Stefan Näwe
Stefan Näwe

Reputation: 3104

If you want to see all files at a given commit use git ls-tree -r $COMMITID

Upvotes: 1

Andomar
Andomar

Reputation: 238048

You can find all commits that deleted files like:

git log --diff-filter=D --name-only --oneline
  • --diff-filter=D selects only files that are deleted
  • --name-only shows the filenames
  • --oneline uses a one-line commit description

Upvotes: 1

Related Questions