LoginSignup
0
4

More than 5 years have passed since last update.

git logに出てこないコミットの内容を確認する

Last updated at Posted at 2019-02-10

rebabse で squash したコミットの中に最新のソースには残っていないコードがあった。

それを復活させる必要がでてしまった。

コピペで済ませたいのでコードが存在したときの hash が知りたい。

けど squash したコミットは git log では hash が確認できない。

困った。

という時のお話。

当たり前のことなのかもしれないが、備忘録としてメモメモ。

Answer

.git/logs/HEAD を見る。

詳しく

※ 実際に復活させたかったのは仕事のコードなのでここには載せられません。代わりに OSS で説明します。

これが git log の状態。
最後のコミットがいくつかのコミットを squash したもの。
当然 squash されたコミットは出てこない。

$ git log
commit bda4848fdbff6bf95fe45eeaae0d972cce1837ac
Author: tommarute <tommarute@gmail.com>
Date:   Wed Dec 19 19:55:42 2018 +0900

    marathon-sd - use Tasks.Ports instead of PortDefinitions.Ports if RequirePorts is false (#5022)

    Signed-off-by: tommarute <tommarute@gmail.com>

commit dbd1d58c894775c0788470944b818cc724f550fb
Author: Simon Pasquier <spasquie@redhat.com>
Date:   Mon Dec 17 16:12:01 2018 +0100

    *: cut v2.6.0 (#5008)

    Signed-off-by: Simon Pasquier <spasquie@redhat.com>

しかし .git/logs/HEAD には log が残っている。

$ less .git/logs/HEAD
(omit...)
612e4f44dd3c9d11452fa469c8658850365e3ee0 3bdfd8f909275f08a84fe59aac5529fbc898d075 tommarute <tommarute@gmail.com> 1545911430 +0900      commit: Rename marathonTestAppListWithPortDefinitionsRequirePorts and its test
3bdfd8f909275f08a84fe59aac5529fbc898d075 25eb66b5c26b2422e52a1b3412e39bed0f768cd3 tommarute <tommarute@gmail.com> 1545911520 +0900      commit: Undo marathonTestAppListWithPortDefinitions
25eb66b5c26b2422e52a1b3412e39bed0f768cd3 76f2adc84401a2def5d8c7c34bd445a1f98f3cc7 tommarute <tommarute@gmail.com> 1545911700 +0900      commit: Remove marathonTestAppListWithContainerNetworkAndPorts

あとはお目当てのコミットの hash を URL に入れてブラウザで見るだけ!

https://github.com/tommarute/prometheus/commit/{hash}

以上

0
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
0
4