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 current level, either from the index, or the current working directory if that’s easier.
Essentially it would give a directory listing similar that that you would see on Github. Coming from Windows, I’m not too familiar with the right way of doing the globbing(?).
(late edit for a feature added in Git 1.8.5, after the question and answer were written:)
Git’s pathspecs ordinarily match
*with any path substring, including/separators, but you can use shell pathname-matching conventions by adding a magic:(glob)prefix. So to list just the files in the current directory,As a side note, you can do many more things with those magic prefixes, chase that link.
You can also turn on shell-style globbing with the
--glob-pathspecsoption on the Git command itself, soOriginal answer, still works:
I think you want
git ls-tree HEADsed’d to taste. The second word of ls-tree’s output will betreefor directories,blobfor files,commitfor submodules, the filename is everything after the ascii tab.Edit: adapting from @iegik’s comment and to better fit the question as asked,
will list the indexed files starting at the current level and collapse directories to their first component.
Further edit: another way to do it is
and you can use
git ls-tree‘s options for some nice seasoning.