git count files in the staged index

前端 未结 8 506
难免孤独
难免孤独 2021-02-01 12:05

I\'m trying to figure out how to easily count the files in my uncommitted index.

I\'ve tried:

git status | grep \'#\' | wc -l

but there

相关标签:
8条回答
  • 2021-02-01 13:00

    If you want something a script can use:

    git diff --cached --numstat | wc -l

    If you want something human readable:

    git diff --cached --stat

    0 讨论(0)
  • 2021-02-01 13:02

    Below should cover for all cases (new, modified, deleted and even untracked), it returns a number.

    (git status -s |select-string -Pattern "^\s*[A|\?|D|M]" -AllMatches).Matches.Count

    0 讨论(0)
提交回复
热议问题