Git diff –stat explanation

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

For example:

  • (git) diff output relative path?
  • Merging with “git mergetool”
  • Git file permissions on Windows
  • Can I generate a “merge tool viewable” diff output with git?
  • Why does git difftool use git diff instead?
  • What does interdiff do that diff cannot?
  • git diff --stat master HEAD^

    Outputs (truncated):

    Site/index.php | 118 ++--

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

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

  • how do I determine whether git history is linear?
  • How to prefer files from one branch during a merge?
  • how to put an eclipse project into github
  • Force file to always produce merge conflict on change
  • When you clone a repo like Laravel into an existing project do you pull it in as submodule even if you're not planning to contribute?
  • Why is folder rename, git push to new remote branch slow
  • 3 Solutions collect form web for “Git diff –stat explanation”

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

    See also:

    man diffstat
    

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

    Parameters:

    • diff = Show diff
    • –numstat = show the number of lines inserted and removed
    • @{1 day ago} = Period.

    Output:
    0 1 WebContent/WEB-INF/tags/Grid.tag
    38 30 ant/build.xml

    • Column1 = inserted
    • Column2 = removed

    PS: Columns are separeted by tab (\t)

    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 118 gives 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.

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

    On CHANGES.txt since 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.py you’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.

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

    Hope that helps.

    Git Baby is a git and github fan, let's start git clone.