I\'m using msysgit (1.7.9), and I\'m looking for the right invocation of the git ls-files command to show just the (tracked) files and directories at the curren
git ls-tree is good and all, but I can't figure out how to specify the index as the . (Although I'm sure there's bound to be some all-caps reference to do just that.)
Anyhow, ls-files implicitly works on the index so I might as well use that:
$ git ls-files | cut -d/ -f1 | uniq
This shows files and directories only in the current directory.
Change cut's -f argument to control depth. For instance, -f-2 (that's dash two) shows files and directories up to two levels deep:
$ git ls-files | cut -d/ -f-2 | uniq
IF you specify the argument to ls-files, make sure to increase -f to accommodate the leading directories:
$ git ls-files foo/bar | cut -d/ -f-3 | uniq