Git - 如果我有 SHA-1 哈希值,则查看与以前版本差异的最简单方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6128131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:00:15  来源:igfitidea点击:

Git - easiest way to see diff with previous version if I have the SHA-1 hash

gitgit-diff

提问by Ryan Lundy

A colleague of mine checked in some changes to Git, and I wanted to see exactly what those changes were. In other words, the diff between his check-in and its parent.

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

What seemed logical to me was to run this command:

对我来说合乎逻辑的是运行这个命令:

git diff shaOfHisCheckIn

But this didn't work. It appears to show the diff between that SHA-1 hash and my current working copy.

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

What's the correct command to show the diff between a given SHA-1 hash and its parent?

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

回答by Simon Whitaker

git showis your friend:

git show是你的朋友:

git show shaOfHisCheckIn

回答by Denilson Sá Maia

If you want to view the diff visually in kdiff3, meld, kompare, xxdiff, tkdiff, diffuse

如果您想直观地查看kdiff3, meld, kompare, xxdiff, tkdiff, diffuse...

git difftool --dir-diff shaOfHisCheckIn^!

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

git difftool -t meld -d shaOfHisCheckIn^!

回答by Vinoth Gopi

Try this:

尝试这个:

git diff shaOfHisCheckIn^ shaOfHisCheckIn

or

或者

git diff shaOfHisCheckIn{^,}

回答by Jonas Heidelberg

git diff shaOfHisCheckIn shaOfHisCheckIn^

git diff shaOfHisCheckIn shaOfHisCheckIn^