git show 输出 merge diff

25 May 2016

我经常使用 git show 来查看某个 commit 的具体修改. 但 git-show 不会显示 merge commit diff. 这是因为 merge commit 有多个 parent. man 中没有给出任何有关的选项.

经常我需要在主线代码上 (仓库采用 github-flow) 查看其它人的修改. 一个方便的命令是 tig --first-parent -m --find-copies-harder. 试了一下,git-show 也接受 --first-parent 参数,输出也确实是想要的.

menghan@air:~/douban/frodo (git::b2) $ git show --first-parent
commit 87172baf49a8f243b0d5f5d266fa546ed5200715
Merge: 904e609 c8bc127
Author: Menghan <menghan@douban.com>
Date:   Wed May 25 10:20:19 2016

    Merge branch 'b1' into b2

diff --git a/frodo.thrift b/frodo.thrift
index d9336a0..f253251 100644
--- a/frodo.thrift
+++ b/frodo.thrift
@@ -9,7 +9,7 @@ struct DiscussionObj {
 }

 struct DiscussionMessageObj {
-       1
+
     1: required string id,
     2: required string author_id,
     3: required string text,
comments powered by Disqus