How can I make git show a list of the files that are being tracked?

Question

Using command line git, how can I make git show a list of the files that are being tracked in the repository?

Answer

If you want to list all the files currently being tracked under the branch master, you could use this command:

git ls-tree -r master --name-only

If you want a list of files that ever existed (i.e. including deleted files):

git log --pretty=format: --name-only --diff-filter=A | sort - | sed '/^$/d'

How do I revert a Git repository to a previous commit?

Reduce git repository size