Answers:
您可以使用git ls-files -v
。如果打印的字符是小写字母,则文件被标记为假定不变。
要仅打印未更改的文件,请使用:
git ls-files -v | grep '^[[:lower:]]'
要拥抱您的懒惰程序员,请将其变成git别名。编辑.gitconfig
文件以添加以下代码段:
[alias]
ignored = !git ls-files -v | grep "^[[:lower:]]"
现在键入git ignored
将为您提供如下输出:
h path/to/ignored.file
h another/ignored.file
[alias]
我的” 部分下添加的内容.gitconfig
:ignored = !git ls-files -v | grep "^[[:lower:]]"
git ls-files -v `git rev-parse --show-toplevel` | grep "^[a-z]"
git ls-files -v | grep "^[a-z]"
恕我直言,git hidden
最好标记为的文件--assume-unchanged
:
git config --global alias.hidden '!git ls-files -v | grep "^[a-z]"'
这是我拥有的相关别名的列表~/.gitconfig
:
[alias]
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
unhide-all = update-index --really-refresh
hidden = !git ls-files -v | grep \"^[a-z]\"
ignored = !git status -s --ignored | grep \"^!!\"
要使其在子目录和支持参数中起作用:
hidden = "!f(){ git -C \"$GIT_PREFIX\" ls-files -v \"$@\" | grep \"^[a-z]\";}; f"
ignored = "!f(){ git -C \"$GIT_PREFIX\" status -s --ignored \"$@\" | grep \"^!!\";}; f"
例如:
# cd target
# git ignored classes
对我来说,大多数隐藏文件都带有标志标记h
,尽管根据以下手册,实际上还有其他几个标志git-ls-files
-v
:
-v Similar to -t, but use lowercase letters for files that are marked as assume unchanged (see git-update-index(1)).
关于git ls-files
-t
:
This option (-t) identifies the file status with the following tags (followed by a space) at the start of each line: H cached S skip-worktree M unmerged R removed/deleted C modified/changed K to be killed ? other
hidden = "!f() { git ls-files -v \"$@\" | grep \"^[a-z]\"; }; f"
和ignored = "!f() { git status -s --ignored \"$@\" | grep \"^!!\"; }; f"
。例如,这允许git ignored -- PATH1 PATH2
仅列出某些路径中的被忽略文件(在您有很多被忽略文件时很有用)。
该命令对我来说更加一致。它将仅打印列为“假定未更改”的文件。
git ls-files -v|grep "^h"
我已经在不同的环境中使用了很多次,并且效果很好。
grep "^h"
的,而不是单引号