List all the files that ever existed in a Git repository

Do you have a clean way to list all the files that ever existed in specified branch?


Solution 1:

This is a simplified variation of Strager's solution:

git log --pretty=format: --name-status | cut -f2- | sort -u

Edit: Thanks to Jakub for teaching me a bit more in the comments, this version has a shorter pipeline and gives git more opportunity to get things right.

git log --pretty=format: --name-only --diff-filter=A | sort -u

Solution 2:

This does the right thing for checking if a filename was ever present in the repo not just on the current branch.

git log --all --pretty=format: --name-only --diff-filter=A | sort - | grep fubar

Solution 3:

You can run git-log --name-status, which echoes something like:

commit afdbbaf52ab24ef7ce1daaf75f3aaf18c4d2fee0
Author: Your Name <[email protected]>
Date:   Tue Aug 12 13:28:34 2008 -0700

    Added test file.

A       test

Then extract files added:

git-log --name-status | sed -ne 's/^A[^u]//p' | sort -u