【问题标题】:Git - easiest way to see diff with previous version if I have the shaGit - 如果我有 sha,查看与以前版本的差异的最简单方法
【发布时间】:2011-05-25 17:01:19
【问题描述】:

我的一位同事检查了 Git 的一些更改,我想看看这些更改到底是什么。换句话说,他的签到和它的父母之间的差异。

在我看来合乎逻辑的是运行这个命令:

git diff shaOfHisCheckIn

但这没有用。它似乎显示了该 SHA 和我当前的工作副本之间的差异。

显示给定 SHA 与其父级之间差异的正确命令是什么?

【问题讨论】:

    标签: git git-diff


    【解决方案1】:

    git show是你的朋友:

    git show shaOfHisCheckIn
    

    【讨论】:

    • 谢谢,这正是我所需要的,而且很容易记住和输入。
    • 不客气!顺便说一下,它也适用于标签 (git show <tag>) - 这是一个非常有用的命令。
    【解决方案2】:

    如果您想在kdiff3meldkomparexxdifftkdiffdiffuse 中直观地查看差异...

    git difftool --dir-diff shaOfHisCheckIn^!
    
    git difftool --tool=meld --dir-diff shaOfHisCheckIn^!
    
    git difftool -t meld -d shaOfHisCheckIn^!
    

    【讨论】:

      【解决方案3】:

      试试这个:

      git diff shaOfHisCheckIn^ shaOfHisCheckIn
      

      git diff shaOfHisCheckIn{^,}
      

      【讨论】:

        【解决方案4】:

        git diff shaOfHisCheckIn shaOfHisCheckIn^

        【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-01-06
        • 1970-01-01
        • 2021-04-16
        • 2013-05-24
        • 1970-01-01
        • 1970-01-01
        • 2013-11-17
        相关资源
        最近更新 更多