8

追跡されていないファイルがあるかどうかをすばやく検出する方法はありますか?

追跡されていないすべてのファイルを一覧表示できます

git ls-files --other --directory --exclude-standard

ただし、追跡されていないファイルが多数ある場合、これは遅くなります。git diff -q追跡されていないファイルが存在するかどうかを終了ステータスが判断する場所のようなものはありますか?

4

2 に答える 2

22

最初の追跡されていないファイルを見たときに必要なものがある場合は、すぐに終了してください。

あなたがGNU/何かを使っているなら

git ls-files --other --directory --exclude-standard | sed q1

ある場合はrc1を設定します

さもないと、

anyuntracked() {
    return `git ls-files -o --directory --exclude-standard | sed q | wc -l`
}
anyuntracked

同じ仕事をします

于 2012-06-13T22:09:01.467 に答える
3

git status追跡されていないファイルがあれば通知します。

出力例:

remco@Prosperpine ~/code/Sick-Beard (master) $ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   init.osx
nothing added to commit but untracked files present (use "git add" to track)
于 2012-06-13T18:43:35.377 に答える