git ls-files 没有提供一种方法来做到这一点,所以我想出了这个:
git ls-files; git status --porcelain | grep ^?? | cut -d' ' -f2
但我想知道是否有一个 git native 可以做到这一点以使其可移植?
简单的技巧(使用git clean):
git clean -n -d -x
Run Code Online (Sandbox Code Playgroud)
这将列出(将被删除)所有被忽略的和私有的文件。
但这不是基于管道命令。
也许:
git ls-files --others --exclude-standard -z
Run Code Online (Sandbox Code Playgroud)
(来自git-ready)
--others lists untracked files
--exclude-standard uses .gitignore and the default git excludes
-z null-delimited output
Run Code Online (Sandbox Code Playgroud)