2

I'm doing a git tutorial and I would like someone tells me if my interpretation of this message is correct:

$ git diff HEAD diff --git a/octocat.txt b/octocat.txt index 7d8d808..e725ef6 100644 --- a/octocat.txt +++ b/octocat.txt @@ -1 +1 @@ -A Tale of Two Octocats +[mA Tale of Two Octocats and an Octodog 

If I understood well, the command tells you what differences are between your last commit and the present moment, right?.

diff --git a/octocat.txt b/octocat.txt 

This line tells you that octocat.txt has been modified. What I don't know here it's what a/ and b/ mean.

--- a/octocat.txt +++ b/octocat.txt 

Line with --- it's the document before being modified and line with +++ refers to the document after being modified.

@@ -1 +1 @@ 

this it's a unified diff hunk identifier. Unified format it's used to display changes between files, right? I'm not native English and I want to be sure I understood it.

-A Tale of Two Octocats +[mA Tale of Two Octocats and an Octodog 

And finally, here is displayed what was deleted and what was added.

Thanks ;)

3
  • 1
    a/ and b/ are just there to differentiate between the old and new file, they are dummy identifiers (diff --git file file wouldn't make much sense). Otherwise your analysis is spot on! Commented Aug 21, 2014 at 9:31
  • yep ... not sure what the question is , since you seem right Commented Aug 21, 2014 at 9:36
  • @Noctis, I think you're right. A better question could be "Is correct this interpretation about a git diff HEAD message?". I'm going to edit it. Thanks Commented Aug 21, 2014 at 9:58

1 Answer 1

1

a/ and b/ are just there to differentiate between the old and new file, they are dummy identifiers (diff --git file file wouldn't make much sense). Otherwise your analysis is spot on!

From the git diff man page:

git diff [--options] <commit> [--] [<path>...]
This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.

Although, most of the time, you will be more likely to simply use git diff (without any arguments) to show what changes are in your working copy, but have not yet been added to the index (in other words: "have not yet been staged").

  • git diff HEAD: shows every change to tracked files not yet committed
  • git diff: shows changes relative to the index (i.e. not yet staged)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.