2
git show --name-only

does what i want, but there's a header, which my script then mangles

git show --name-only | head -n 5

Shows the bit i don't want.

git show --name-only | tail -n +7

Nails it.

Surely there is a better way?

Specifically, I want the names (and paths) of all the files which exist and are version controlled in the current state of my repository.

1
  • 1
    Do you want to list all the files, or the files in the latest commit? git show by default lists all the files modified in the latest commit, not all the files. Commented Feb 13, 2015 at 18:59

2 Answers 2

1

I believe you want:

git ls-files

2
  • With -r to show files in sub directories. Should be git ls-files -r HEAD.
    – Maroun
    Commented Feb 13, 2015 at 18:58
  • ls-files lists all files. I think git show by default lists the files modified in the latest commit. Commented Feb 13, 2015 at 19:01
1

First a clarification git show will - without any flags - list the files of the latest commit, not of all added files.

You can use the --pretty=oneliner to ensure only the first line will contain information. So by using

git show --name-only --pretty=oneline | tail -n +2

You make sure you will never (for future versions) cut away real information.

In case you want a list of all files under subversioning, you should use git ls-files as answered by @DavidHoelzer.

0

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