我有一个 git 提交,需要获取插入和删除的总数。
我知道“git show <SHA>
”显示了我提交的详细信息,但我不确定如何仅从特定提交中获取更改总数。
git diff --stat <SHA1> <SHA2>
也不起作用,因为我应该只使用一次提交。
如果您有任何信息,请与我分享。
最佳答案
您应该仍然可以使用 git diff --stat
:
git diff --stat <SHA>~ <SHA>
# or, for a global total only:
git diff --shortstat <SHA>~ <SHA>
~
指的是 <SHA>
的直接父级.您只使用了一个 <SHA>
:提交<SHA>
, 和 its direct parent <SHA>~
.
例如:
C:\Users\vonc\prog\git\git>git diff --stat e646ab9cf83025e1000db6ec3c1716f978b099f2~ e646ab9cf83025e1000db6ec3c1716f978b099f2
po/TEAMS | 8 +-
po/ca.po | 3949 ++++++++++++++++++++++++++++++-------------------------
po/de.po | 3776 +++++++++++++++++++++++++++++-----------------------
po/fr.po | 3746 +++++++++++++++++++++++++++++-----------------------
po/git.pot | 3547 +++++++++++++++++++++++++++----------------------
po/sv.po | 3723 +++++++++++++++++++++++++++++-----------------------
po/vi.po | 3762 +++++++++++++++++++++++++++++-----------------------
po/zh_CN.po | 4217 +++++++++++++++++++++++++++++++++--------------------------
8 files changed, 15007 insertions(+), 11721 deletions(-)
总计:
C:\Users\vonc\prog\git\git>git diff --shortstat e646ab9cf83025e1000db6ec3c1716f978b099f2~ e646ab9cf83025e1000db6ec3c1716f978b099f2
8 files changed, 15007 insertions(+), 11721 deletions(-)
关于Git:如何从单个 git 提交中获取 +/-(插入和删除)的总数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33087290/