3 回答

TA貢獻1797條經驗 獲得超6個贊
您可以使用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

TA貢獻1887條經驗 獲得超5個贊
一線
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
關于文件狀態
對我來說,大多數隱藏文件都用flag標記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

TA貢獻1805條經驗 獲得超9個贊
這個命令對我來說更加一致。它將僅打印列為“假定未更改”的文件。
git ls-files -v|grep "^h"
我已經在不同的環境中使用了很多次,并且效果很好。
- 3 回答
- 0 關注
- 497 瀏覽
添加回答
舉報