gitで作業している時に「このコミットでのdiffなんだっけ?」と確認したい時があります。
そんなとき、コマンドベースで確認するための方法です。
前提
以下のようなコミットログがあるとする。
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
このコミットログは直前のコミットはabcdefg
、その前のコミットはhijklmn
ということを意味している。
diffの見方
abcdefg
(直前のコミット)でのdiffを見るには以下のようにする
git show abcdefg
もしくは以下でもOK
git diff HEAD
hijklmn
でのdiffを見るには以下のようになる
git show hijklmn
もしくは以下でもOK
git diff HEAD^2
by @nishina555