List all files that are not ignored by .gitignore

后端 未结 2 1065
情歌与酒
情歌与酒 2021-02-13 18:37

I would like to list all files that are not ignored by .gitignore, ie all source files of my repository.

ag does it well by default, but I\'m not aware of

2条回答
  •  你的背包
    2021-02-13 18:50

    git status --short| grep  '^?' | cut -d\  -f2- 
    

    will give you untracked files.

    If you union it with git ls-files, you've got all unignored files:

    ( git status --short| grep '^?' | cut -d\  -f2- && git ls-files ) | sort -u
    

    you can then filter by

    ( xargs -d '\n' -- stat -c%n 2>/dev/null  ||: )
    

    to get only the files that are stat-able (== on disk).

提交回复
热议问题