DEV Community

loading...

Git command for checking differences at a specific commit

Toshiharu Nishina
A web developer for the fifth year.Rails/React/GraphQL.
Updated on ・1 min read

Example

Suppose there is a commit log like the following.

commit abcdefg (HEAD -> feature/test)
Merge: xxxxxx
Author: nishina555
Date:   Fri Jun 15 15:34:05 2018 +0900

    Merge branch 'master' of https://github.com/xxxx into feature/test

commit hijklmn (origin/master, master)
Author: nishina555
Date:   Fri Jun 15 13:34:14 2018 +0900

    test
Enter fullscreen mode Exit fullscreen mode

This commit log means that the last commit is abcdefg and the previous commit is hijklmn.

How to check diff

To check diff in abcdefg (last commit)

git show abcdefg
Enter fullscreen mode Exit fullscreen mode

Or even below

git diff HEAD
Enter fullscreen mode Exit fullscreen mode

To check diff in hijklmn

git show hijklmn
Enter fullscreen mode Exit fullscreen mode

Or even below

git diff HEAD^2
Enter fullscreen mode Exit fullscreen mode

by @nishina555

Discussion (0)