c4baf058
c4baf058

Reputation: 225

How to list every file for every revision in Git (like Mercurial's hg manifest --all)?

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).

Upvotes: 2

Views: 586

Answers (2)

manojlds
manojlds

Reputation: 301087

This should give all the files ever existed:

git log --pretty=format: --name-only | sort | uniq

Upvotes: 2

Greg Hewgill
Greg Hewgill

Reputation: 992857

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.

Upvotes: 0

Related Questions