git 显示提交消息之间的差异
git show difference between commit messages
假设我有两个完全相同的提交,但它们的消息不同,我如何在 git 中看到它?
如何制作这个;假设我在 master 上,在任何提交上;
git checkout -b test
git commit --amend
// now edit the commit message
git diff master
这显示了一个空输出。我发现在提交消息中看到这种差异的唯一方法是:
git show --stat master > m
git show --stat > t
diff m t
产生这样的输出(我确实稍微修改了 git 日志输出格式):
1c1
< 65fb678 - (HEAD, test) add bcdef (Fri, 8 Jan 2016 11:23:51 +0100) <Chris Maes>
---
> 7f9c3ee - (master) add bcd (Wed, 6 Jan 2016 11:28:10 +0100) <Chris Maes>
是否有任何 git 命令可以仅查看提交消息的差异(有或没有正常的 git 输出)?
注意 我的问题与 this question 相似,但我正在寻找一个 git 命令这个。
这对我有用:
diff -w <(git rev-list --max-count=1 --format=%B SHA1) <(git rev-list --max-count=1 --format=%B SHA2)
-w
忽略空格差异。
<( ... )
语法创建了一个临时命名管道,它使 git show
命令的标准输出看起来和行为都像一个文件,允许 diff 对预期的输入类型进行操作。
--format=%B
显示提交消息的原始消息头+正文
您可以将 diff -w
替换为 wdiff
以进行逐字比较。
编辑
如果您确实需要 git
命令,请将此 git 别名添加到 ~/.gitconfig
:
[alias]
msgdiff = "!bash -c '[ $# = 2 ] && diff -w <(git rev-list --max-count=1 --format=%B \"\") <(git rev-list --max-count=1 --format=%B \"\")' -"
那你可以做
git msgdiff SHA1 SHA2
假设我有两个完全相同的提交,但它们的消息不同,我如何在 git 中看到它?
如何制作这个;假设我在 master 上,在任何提交上;
git checkout -b test
git commit --amend
// now edit the commit message
git diff master
这显示了一个空输出。我发现在提交消息中看到这种差异的唯一方法是:
git show --stat master > m
git show --stat > t
diff m t
产生这样的输出(我确实稍微修改了 git 日志输出格式):
1c1
< 65fb678 - (HEAD, test) add bcdef (Fri, 8 Jan 2016 11:23:51 +0100) <Chris Maes>
---
> 7f9c3ee - (master) add bcd (Wed, 6 Jan 2016 11:28:10 +0100) <Chris Maes>
是否有任何 git 命令可以仅查看提交消息的差异(有或没有正常的 git 输出)?
注意 我的问题与 this question 相似,但我正在寻找一个 git 命令这个。
这对我有用:
diff -w <(git rev-list --max-count=1 --format=%B SHA1) <(git rev-list --max-count=1 --format=%B SHA2)
-w
忽略空格差异。<( ... )
语法创建了一个临时命名管道,它使git show
命令的标准输出看起来和行为都像一个文件,允许 diff 对预期的输入类型进行操作。--format=%B
显示提交消息的原始消息头+正文
您可以将 diff -w
替换为 wdiff
以进行逐字比较。
编辑
如果您确实需要 git
命令,请将此 git 别名添加到 ~/.gitconfig
:
[alias]
msgdiff = "!bash -c '[ $# = 2 ] && diff -w <(git rev-list --max-count=1 --format=%B \"\") <(git rev-list --max-count=1 --format=%B \"\")' -"
那你可以做
git msgdiff SHA1 SHA2