git show commit idを確認する

git showコマンドを使用して、コミット情報と変更を確認できます。

1. 特定のコミット情報の確認

git show <commit id>はcommit idの情報と修正を示しています。

$ git show 3cb225dc74b9f0faf0858fd4602ceaadb3e9d30c

commit 3cb225dc74b9f0faf0858fd4602ceaadb3e9d30c
Author: Peiyong Lin <lpy@google.com>
Date:   Mon Sep 28 23:17:37 2020 -0700

    [GraphicsEnvironment] Avoid null access.

    Currently when debug layer apk is not installed, GraphicsEnvironment
    logs the message and proceeds, which results in null pointer access
    crash when later trying to access primaryAbi. Avoid null access by an
    early return statement.

diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java
index df1f1b21eba..e77b163743f 100644
--- a/core/java/android/os/GraphicsEnvironment.java
...

commit idは7桁まで入力できます。

$ git show 3cb225d

commit 3cb225dc74b9f0faf0858fd4602ceaadb3e9d30c
Author: Peiyong Lin <lpy@google.com>
Date:   Mon Sep 28 23:17:37 2020 -0700
...

2. 最新のコミット情報の確認

git showは最新のコミットの情報を出力します。

$ git show

commit 8c3b567c36ef56e03a67aac83fe045c4b239217e (HEAD -> master, origin/master, origin/HEAD)
Merge: 4f94f12cba2 f7dc3f6788d
Author: Nathan Harold <nharold@google.com>
Date:   Fri Dec 18 00:38:04 2020 +0000

    Merge "Fix permission on TM#isDataEnabled"

HEADは最新のコミットを指すので、以下のように入力してもよい。

$ git show HEAD

commit 8c3b567c36ef56e03a67aac83fe045c4b239217e (HEAD -> master, origin/master, origin/HEAD)
Merge: 4f94f12cba2 f7dc3f6788d
Author: Nathan Harold <nharold@google.com>
Date:   Fri Dec 18 00:38:04 2020 +0000

    Merge "Fix permission on TM#isDataEnabled"

3. 最新の直前のコミット情報の確認

HEAD^ は最新の commit の以前の commit を指します。 HEAD^^^ は最新 commit の 3 つ前の commit を指します。

$ git show HEAD^

commit 4f94f12cba24c7d2c03447c742df5cf3a894307a
Merge: c0de8cfcfad 3fa9158be79
Author: Wonsik Kim <wonsik@google.com>
Date:   Fri Dec 18 00:09:34 2020 +0000

    Merge "MediaCodecInfo: do not alter performance points for 32-bit processes"

3.1 git show HEAD~1

HEAD~1HEAD^ と同じ意味です。 HEAD~3HEAD^^^ と同じ意味になります。

$ git show HEAD^^^
commit 7c9eef5613cd6e9716dd608cbc08715c4f2ff19f
Merge: b8ff8f238e2 e92ddfef4ff
Author: Hui Wang <huiwang@google.com>
Date:   Thu Dec 17 22:53:31 2020 +0000

    Merge "RCS Provisioning APIs for Single Registration"


$ git show HEAD~3
commit 7c9eef5613cd6e9716dd608cbc08715c4f2ff19f
Merge: b8ff8f238e2 e92ddfef4ff
Author: Hui Wang <huiwang@google.com>
Date:   Thu Dec 17 22:53:31 2020 +0000

    Merge "RCS Provisioning APIs for Single Registration"

git logコマンドで、最新のコミットの3つ前のコミットが正しいことを確認できます。

$ git log -4
commit 8c3b567c36ef56e03a67aac83fe045c4b239217e (HEAD -> master, origin/master, origin/HEAD)
Merge: 4f94f12cba2 f7dc3f6788d
Author: Nathan Harold <nharold@google.com>
Date:   Fri Dec 18 00:38:04 2020 +0000

    Merge "Fix permission on TM#isDataEnabled"

commit 4f94f12cba24c7d2c03447c742df5cf3a894307a
Merge: c0de8cfcfad 3fa9158be79
Author: Wonsik Kim <wonsik@google.com>
Date:   Fri Dec 18 00:09:34 2020 +0000

    Merge "MediaCodecInfo: do not alter performance points for 32-bit processes"

commit c0de8cfcfadf018828210a4d4d7ae939e0facd48
Merge: 7c9eef5613c 16624a11a8a
Author: Treehugger Robot <treehugger-gerrit@google.com>
Date:   Thu Dec 17 22:58:32 2020 +0000

    Merge "Use find-copy-subdir-files macro to eliminate foreach calls"

commit 7c9eef5613cd6e9716dd608cbc08715c4f2ff19f
Merge: b8ff8f238e2 e92ddfef4ff
Author: Hui Wang <huiwang@google.com>
Date:   Thu Dec 17 22:53:31 2020 +0000

    Merge "RCS Provisioning APIs for Single Registration"
codechachaCopyright ©2019 codechacha