git: diff header – hunk differences (or what does something like “@@ -395,3 +395,2 @@ body {” mean)

On doing a git diff you’ll get a diff header which looks like this:

index 9d6fe59..e072dd6 100644

This means we have a file (hence the file mode) and not a symlink.


Then we have various hunks of differences starting with lines like:

@@ -395,3 +395,2 @@ body {

Here the format is: @@ from-file-range to-file-range @@ [header]. The from-file-range is in the form -<start line>,<number of lines>, and to-file-range is +<start line>,<number of lines>.


-395,3: from file – start line 395, 3 lines

+395,2 to file – start line 395, 2 lines

More info here:

git: what’s the difference between the index, the staging area, the working tree / area,

Your working area (aka workspace or working tree) are the files you’re currently working on.

The index (aka the staging area) is the list of files that you are about to commit to your local repo.

In a nutshell, your workflow is:

Your Working area -> Index -> your local repo

This is very handy: