How can I make git show a list of the files that are being tracked?

前端 未结 4 524
误落风尘
误落风尘 2020-12-04 04:12

Using command line git, how can I make git show a list of the files that are being tracked in the repository?

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 04:46

    You might want colored output with this.

    I use this one-liner for listing the tracked files and directories in the current directory of the current branch:

    ls --group-directories-first --color=auto -d $(git ls-tree $(git branch | grep \* | cut -d " " -f2) --name-only)
    

    You might want to add it as an alias:

    alias gl='ls --group-directories-first --color=auto -d $(git ls-tree $(git branch | grep \* | cut -d " " -f2) --name-only)'
    

    If you want to recursively list files:

    'ls' --color=auto -d $(git ls-tree -rt $(git branch | grep \* | cut -d " " -f2) --name-only)
    

    And an alias:

    alias glr="'ls' --color=auto -d \$(git ls-tree -rt \$(git branch | grep \\* | cut -d \" \" -f2) --name-only)"
    

提交回复
热议问题