how to `git ls-files` for just one directory level.

后端 未结 7 889
广开言路
广开言路 2020-12-31 00:55

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

7条回答
  •  Happy的楠姐
    2020-12-31 01:46

    I think you want git ls-tree HEAD sed'd to taste. The second word of ls-tree's output will be tree for directories, blob for files, commit for submodules, the filename is everything after the ascii tab.

    Edit: adapting from @iegik's comment and to better fit the question as asked,

    git ls-files . | sed s,/.*,/, | uniq
    

    will list the indexed files starting at the current level and collapse directories to their first component.

提交回复
热议问题