Git diff --stat 解释

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7024848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:31:49  来源:igfitidea点击:

Git diff --stat explanation

gitdiffdiffstat

提问by LukasWildas

Git's pull outputhas been explained here fairly well. In spite of this I'm still unsure exactly what the text graph relates to.

Git 的 pull 输出已经在这里很好地解释了。尽管如此,我仍然不确定文本图到底与什么有关。

For example:

例如:

git diff --stat master HEAD^

git diff --stat master HEAD^

Outputs (truncated):

输出(截断):

Site/index.php | 118 ++--

Site/index.php | 118 ++--

While the number of lines modified is clearly displayed as 118, the text graph is a little harder to interpret.

虽然修改的行数清楚地显示为 118,但文本图有点难以解释。

Could this relate to the ratio of added and removed lines?

这可能与添加和删除行的比率有关吗?

采纳答案by Patrick B.

Yes it's the ratio of added and removed lines.

是的,这是添加和删除行的比率。

See also:

也可以看看:

man diffstat

回答by Edgard Leal

git diff --numstat "@{1 day ago}"

Parameters:

参数:

  • diff= Show diff
  • --numstat= show the number of lines inserted and removed
  • @{1 day ago}= Period.
  • diff= 显示差异
  • --numstat= 显示插入和删除的行数
  • @{1 day ago}= 时期。


Output

输出

0   1   WebContent/WEB-INF/tags/Grid.tag
38  30  ant/build.xml
  • Column 1 (containing 038) = inserted
  • Column 2 (containing 130) = removed
  • 第 1 列(包含038)= 插入
  • 第 2 列(包含130)= 已删除

PS: Columns are separated by tab (\t).

PS:列由制表符 ( \t)分隔。

回答by Ofir Farchy

As I answered here:

正如我在这里回答的那样:

It supposed to reflect the amount of changes (in lines) of each file listed.
Plus signs for additions, minuses for deletions.

它应该反映列出的每个文件的更改量(以行为单位)。
加号表示添加,减号表示删除。

The 118gives the amount of changed lines, and the -/ +gives you the proportion of deletions/additions.
When the amount of changes can fit a line you'll get '+' per addition, '-' per deletion;
Otherwise, this is an approximation, e.g.

118给出了改变线的量,-/ +为您提供了删除/添加的比例。
当更改量可以容纳一行时,每次添加都会得到 ' +',每次删除都会得到' -';
否则,这是一个近似值,例如

CHANGES.txt     |   47 +++++++++++++++++++++++++++++++++
make-release.py |   77 +++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 102 insertions(+), 22 deletions(-)

On CHANGES.txtsince you can see that there are no '-', and since 47 '+' are a lot you have a proportionate amount of them (i.e. 100%).
On make-release.pyyou'll see x39'+' standing for 55 additions and x16'-' standing for 22 deletions.
Exactly as their proportion, and just the amount to fit output screen.

CHANGES.txt因为你可以看到有没有“ -”,并自47“ +”很多,你对他们有相当的数量(即100%)。
在上,make-release.py您会看到x39' +' 代表 55 次添加,而x16' -' 代表 22 次删除。
完全按照它们的比例,只是适合输出屏幕的数量。

The amount of signs per line the a GCDmultiple that fits the line width.

每行的符号数量GCD是适合线宽的倍数。

Hope that helps.

希望有帮助。