Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to list all files currently under source control in git? (Not just those that have been modified).

share|improve this question
add comment

2 Answers 2

up vote 31 down vote accepted

If you want to list all files for a specific branch, e.g. master:

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

The -r option will let it recurse into subdirectories and print each file currently under version control. You can also specify HEAD instead of master to get the list for any other branch you might be in.

If you want to get a list of all files that ever existed, see here:

git log --pretty=format: --name-status | cut -f2- | sort -u
share|improve this answer
    
Thanks slhck, exactly what I was after - and useful to know about the second one too. Will mark as correct in 5 and a half minutes when I'm allowed. :-) –  Anonymous May 28 '12 at 13:21
3  
Thanks for the answer. I was looking for this. Note that git ls-tree -r master --name-only would do the same as the first option, without needing the cut. Ah, and you can specify HEAD instead of master if you just want this list for whatever branch you are currently on. –  maurits Sep 13 '12 at 10:15
add comment

I believe you are looking for git-ls-files.

share|improve this answer
1  
git ls-files instead of git ls-tree -r master --name-only is certainly simpler. –  karatedog Oct 22 '13 at 8:14
    
Sorry but my edit wasn't invalid. In current git there is no git-ls-files binary. There is the git binary with the ls-files command. The link to the documentation is correct in content, but technically for an outdated binary. –  JonnyJD Jan 11 at 3:09
add comment

Your Answer

 
discard

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.