6

I am just getting into VC and in particular git. I am aware of basic commands like git add/commit/remote but having a hard time understanding the output:

$ git show f27d852

commit f27d852fc750a9c3f71eaf0acf586164b76faddf
Author: myusername <myemail@gmail.com>
Date:   Tue Jun 28 22:59:35 2016 +0530

    changed color to a different color

diff --git a/css/business-casual.css b/css/business-casual.css
index bbd44d7..ee1765e 100644
--- a/css/business-casual.css
+++ b/css/business-casual.css
@@ -194,5 +194,5 @@ footer p {
 /* CUSTOM CSS - BY ME */

 .brand {
-       color: #ff0000;
-       }
\ No newline at end of file
+       color: #ffdd000;
+       }

What does each line mean? How to read it. can anyone explain?

Thanks dk

dkjain
  • 831
  • 1
  • 9
  • 36
  • 1
    This is just showing you the details of the most recent commit (on the current branch) - metadata plus the diff. Which part in particular is problematic? – Oliver Charlesworth Jul 02 '16 at 10:54
  • I do not understand the following lines: `diff --git a/..... b/` `--- a/... +++ b/..` `@@ -194,5 +194,5 @@ footer p {` (why there is a reference of `footer p{}`, which was never changed and moreover no where near line 194) and the line `\ No newline at end of file` when infact there were blank lines at eof. – dkjain Jul 02 '16 at 11:47
  • The `No newline at end of file` message indicates that one of the files (the first one, in this case) is incomplete. The last line is not terminated by a newline character, as lines in a text file are supposed to be. See [this question](http://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline). The diff output tells you everything about the changes between the two files, even this minor detail that you might not care about. –  Jul 03 '16 at 15:35

2 Answers2

8
commit f27d852fc750a9c3f71eaf0acf586164b76faddf

The sha1 of the commit.

Author: myusername <myemail@gmail.com>

The author's name and email, which might be different from the committer's name and email.

Date:   Tue Jun 28 22:59:35 2016 +0530

The author date, which might be different from the committer date.

changed color to a different color

The commit log message. It could be one line, or the first part + empty line(s) + the other part. The only line or the first part before the empty line(s) is subject, and the other part after the empty line(s) is body.

diff --git a/css/business-casual.css b/css/business-casual.css

The two files that have been compared.

index bbd44d7..ee1765e 100644

bbd44d7 is the sha1 of the blob before the change and ee1765e the sha1 of the blob after the change. You could run git show <blob-sha1> or git cat-file -p <blob-sha1> to see the blob's content.

--- a/css/business-casual.css

The file before the change.

+++ b/css/business-casual.css

The file after the change.

    @@ -194,5 +194,5 @@ footer p {
 /* CUSTOM CSS - BY ME */

 .brand {
-       color: #ff0000;
-       }
\ No newline at end of file
+       color: #ffdd000;
+       }

194 is the diff start line and 5 is the context lines. footer p { indicates where the diff part locates. The lines without prefixing + or - are unchanged lines. If you add one line, it's a +. If you delete a line, it's a -. If you modify a line, it's a - and a +.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
  • Although, I understood most of it from another answer on SO however still thanks for taking the pain to reply to this in a much more detailed manner than the other answer. – dkjain Jul 05 '16 at 17:07
2

It provides the details about commit and then list of changed files with its differencies (see unified diff for details):

# commit id:
commit f27d852fc750a9c3f71eaf0acf586164b76faddf
# author:
Author: myusername <myemail@gmail.com>
# date committed:
Date:   Tue Jun 28 22:59:35 2016 +0530
# commit message:
    changed color to a different color
# difference for css/business-casual.css :
diff --git a/css/business-casual.css b/css/business-casual.css
Zbynek Vyskovsky - kvr000
  • 18,186
  • 3
  • 35
  • 43