1

For example,

hash09  Update something5
hashNew Update something4
hashOld Update something3
hash03  Update something2
hash02  Update something
hash01  Add something

If I want to see what has beed introduced in hashNew, should I use

git diff hashNew..hashOld

or

git diff hashOld..hashNew

or

git diff hashNew~

or

git diff hashNew^
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
Sato
  • 8,192
  • 17
  • 60
  • 115
  • 2
    Possible duplicate of [What are the differences between double-dot ".." and triple-dot "..." in Git diff commit ranges?](https://stackoverflow.com/questions/7251477/what-are-the-differences-between-double-dot-and-triple-dot-in-git-dif) – Tim Biegeleisen Mar 16 '18 at 01:59
  • 1
    `git show hashNew` will show what was introduced in hashNew – mvp Mar 17 '18 at 17:43

2 Answers2

1

You should use:

git diff hashOld hashNew

it produces the same output as:

git diff hashOld..hashNew

Keep in mind that:

  • ^ – indicates the parent commit
  • ~ – indicates the first parent commit

so, in order to use them to see what has been introduced in hasNew, you could write:

git diff hashNew~ hasNew

or

git diff hasNew^ hasNew

with

git diff hashNew^

you would be comparing the working directory with hashOld, since hasOld is the parent commit of hashNew

0

To show what changes are introduced by a particular commit, git show is handy. More info at man git-show.

For more information about the syntax, man gitrevisions gives thorough explanations.

jsageryd
  • 4,234
  • 21
  • 34