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
This has lots of answers... but the best command imo (it doesn't require any piping and is a pure native git command) is just the following. Note that this counts deleted, modified, and added files:
git diff --cached --shortstat
The output is only one line:
X files changed, Y insertions(+), Z deletions(-)
If no changes have been made, it prints nothing (not even a new empty line).
It's also obvious how to get the same result for unstaged changes (just omit the --cached
flag):
git diff --shortstat