LoginSignup
4
4

More than 5 years have passed since last update.

特定のコミットでの差分を見るときのgitコマンド

Last updated at Posted at 2018-06-15

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

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4