Git - easiest way to see diff with previous version if I have the sha

Ryan Lundy picture Ryan Lundy · May 25, 2011 · Viewed 25.2k times · Source

A colleague of mine checked in some changes to Git, and I want to see exactly what those changes were. In other words, the diff between his check-in and its parent.

What seemed logical to me was to run this command:

git diff shaOfHisCheckIn

But this didn't work. It appears to show the diff between that SHA and my current working copy.

What's the correct command to show the diff between a given SHA and its parent?

Answer

Simon Whitaker picture Simon Whitaker · May 25, 2011

git show is your friend:

git show shaOfHisCheckIn