Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: what does the number of +/- signs in diff / merge output mean? [duplicate]

Tags:

git

diff

Possible Duplicate:
Git Merge: What does this mean?
Git diff --stat explanation

Sorry for the stupid question, but i can't find a clear answer anywhere.

When you merge two branches in git, you get an output like that :

 some_file.txt  |  564 ++++++++++++++--

I undestand that + and - mean addition and deletion, but :

  • what does the number of signs represent ? when you have few changes, each sign seem to represent a line, but when you have more signs, i can't get the logic of the representation

  • is it some sort of percentage of changes ? My guess is that the number of signs represents a relative amount of changes - but relative to what ? current file ? the whole merge ?

  • how is it calculated ? Is there any official source about this ? The most accurate answer i had on this by now is "this representation is not very precise"... i'm just curious

like image 335
m_x Avatar asked Dec 07 '12 10:12

m_x


People also ask

What is plus and minus in git?

Plus signs for additions, minuses for deletions.

What does ++ mean in git diff?

When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent: one line that was added does not appear in either file1 or file2.

What does git diff show you?

The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.

How does git diff command work?

Comparing changes with git diffDiffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.


1 Answers

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

EDIT:
the 564 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.

Hope that helps.

like image 86
Ofir Farchy Avatar answered Oct 13 '22 11:10

Ofir Farchy