2

If I do git log <commit-id> --stat or git diff with --stat, I get something like:

myproj/src/__main__.py                             |   1 +
myproj/{ => src}/utils.py                          |   0
myproj/{ => src}/web.py                            |  31 ++++-
3 files changed, 29 insertions(+), 3 deletions(-)

The number next to each file is: number_of_inserts + number_of_deletes. This is not what I want. I want to know the number of lines added and deleted for each file (e.g. +28 -3 instead of 31).

  • I know I could use --numstat instead of --stat, but --numstat will not produce the histogram.
  • I also know that I can use diffstat. For example, git diff <commit-id> | diffstat -f4 -C:

    myproj/src/__main__.py                             |   1    1    0 +
    myproj/src/web.py                                  |  31   28    3 ++++-
    2 files changed, 29 insertions(+), 3 deletions(-)
    

    But here I lose information about file moves/renames (e.g. myproj/{ => src}/web.py).

So how can I get output similar to --stat, but with information about the number of lines added and the number of lines deleted for each file?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Flux
  • 9,805
  • 5
  • 46
  • 92
  • Looks like a duplicate of [this](https://stackoverflow.com/questions/9933325/is-there-a-way-of-having-git-show-lines-added-lines-changed-and-lines-removed). – Jay-Pi Mar 03 '20 at 00:59
  • @Jay-Pi No, that question is about showing the number of lines modified. This question is about showing the number of additions and deletions for each file. I know this because I actually answered the question you linked to. – Flux Mar 03 '20 at 01:08
  • Sorry I didn't read the question carefully. How about `git log --numstat --stat`? The output seems redundant, but it includes the histogram, the number of insertions and deletions of each file, and information on rename. – ElpieKay Mar 03 '20 at 02:39

1 Answers1

0

git log --numstat --stat --oneline outputs the following:

6012d9a9fa69 docs: kvm: Convert timekeeping.txt to ReST format
1       0       Documentation/virt/kvm/index.rst
128     95      Documentation/virt/kvm/{timekeeping.txt => timekeeping.rst}
 Documentation/virt/kvm/index.rst                            |   1 +
 Documentation/virt/kvm/{timekeeping.txt => timekeeping.rst} | 223 +++++++++++++++++++++++++++++++++++++++++++++----------------------------------
 2 files changed, 129 insertions(+), 95 deletions(-)
idlethread
  • 1,111
  • 7
  • 16