列出所有未被.gitignore忽略的文件 [英] List all files that are not ignored by .gitignore
问题描述
我想列出所有未被.gitignore忽略的文件,即我的存储库中的所有源文件.
I would like to list all files that are not ignored by .gitignore, ie all source files of my repository.
ag
默认情况下效果很好,但是我不知道在不安装其他软件的情况下仍然可以使用的方法.
ag
does it well by default, but I'm not aware of an approach that works without installing additional software.
git ls-files
几乎可以很好地工作,但是不考虑已修改/创建的文件,例如,如果我创建了一个新的文件栏而没有提交,则git ls-files
不会显示该文件.
git ls-files
without options works almost well but doesn't take into account the files that have been modified/created, for example if I create a new file bar without commiting it, git ls-files
doesn't show that file.
推荐答案
git status --short| grep '^?' | cut -d\ -f2-
将为您提供未跟踪的文件.
will give you untracked files.
如果将其与git ls-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
然后您可以按
( xargs -d '\n' -- stat -c%n 2>/dev/null ||: )
仅获取可统计的文件(磁盘上的==).
to get only the files that are stat-able (== on disk).
这篇关于列出所有未被.gitignore忽略的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!