Karen Fisher
Karen Fisher

Reputation: 777

What does information between "@@" means in git dif

When I use git diff command in git I see output like this:

@@ -35,14 +41,12 @@

and can't realize what does it mean. I guess that minus means a row when deletion was made, and + is row with insertion. Am I right?

Upvotes: 2

Views: 195

Answers (1)

Yuval Adam
Yuval Adam

Reputation: 165252

A hunk begins with range information and is immediately followed with the line additions, line deletions, and any number of the contextual lines. The range information is surrounded by double-at signs, and combines onto a single line what appears on two lines in the context format (above). The format of the range information line is as follows:

@@ -l,s +l,s @@ optional section heading

The hunk range information contains two hunk ranges. The range for the hunk of the original file is preceded by a minus symbol, and the range for the new file is preceded by a plus symbol. Each hunk range is of the format l,s where l is the starting line number and s is the number of lines the change hunk applies to for each respective file. In many versions of GNU diff, each range can omit the comma and trailing value s, in which case s defaults to 1. Note that the only really interesting value is the l line number of the first range; all the other values can be computed from the diff.

Source: https://en.wikipedia.org/wiki/Diff#Unified_format

Upvotes: 2

Related Questions