Is there a way of having git show lines added, lines changed and lines removed?
You can use:
git diff --numstat
to get numerical diff information.
As far as separating modification from an add and remove pair, --word-diff
might help. You could try something like this:
MOD_PATTERN='^.+(\[-|\{\+).*$' \
ADD_PATTERN='^\{\+.*\+\}$' \
REM_PATTERN='^\[-.*-\]$' \
git diff --word-diff --unified=0 | sed -nr \
-e "s/$MOD_PATTERN/modified/p" \
-e "s/$ADD_PATTERN/added/p" \
-e "s/$REM_PATTERN/removed/p" \
| sort | uniq -c
It's a little long-winded so you may want to parse it in your own script instead.
-
If you want to know the lines added/changed/deleted by a commit with id
commit-id
, you could usegit show commit-id --stat
or
git diff commit-id-before commit-id --stat
-
If you wat to know the lines added/changed/deleted by a range commits, you could use
git diff commit-id1 commit-id2 --stat
-
If you want to know the lines added/changed/deleted by each commit, you could use
git log --stat