2

Mercurial has a command to list every file that the repository has for every revision:

hg manifest --all

Is there an equivalent command in Git? I know about git ls-files, but it only list files from the index (the current revision).

c4baf058
  • 225
  • 2
  • 5
  • Related question (I think): http://stackoverflow.com/questions/543346/git-list-all-the-files-that-ever-existed – JesusFreke Sep 25 '11 at 01:09

2 Answers2

2

This should give all the files ever existed:

git log --pretty=format: --name-only | sort | uniq
manojlds
  • 290,304
  • 63
  • 469
  • 417
  • I guess that the OP will also want to add `--all` to `git log`'s parameters, although even then it will miss dangling commits. – Mark Longair Sep 25 '11 at 15:34
0

You could do this with the following pipeline:

git rev-list HEAD | xargs -L 1 git ls-tree -r | awk '{print $4}' | sort | uniq

This does the following:

  • use git rev-list to get a list of revisions backward from HEAD
  • for each revision, use git ls-tree -r to show the list of files
  • extract just the filenames from the list using awk
  • using sort and uniq, filter out names that are listed more than once

This will give the name of every file that has ever been part of the history of the current HEAD.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285