Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I produce a list of filenames (incl. paths) that git knows about over the course of the whole history?

share|improve this question
up vote 8 down vote accepted

Naive solution:

git rev-list --all | xargs -n1 git ls-tree --full-name -r --name-only  | sort -u

This lists all commits, then uses that to list all files in every commit. sort deduplicates. Only works for small-ish repos though as it takes a long time.

A better solution would be to use libgit2 to do the same, should be faster but requires some programming. A quick hack that implements this can be found on github. It uses pygit2 and is an order of magnitude faster than the shell pipeline above.

share|improve this answer
Awesome, thanks a lot. – timmy Dec 17 '12 at 12:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.