git 使用 gitk,我可以看到 2 次提交之间的区别吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13715710/
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
Using gitk, can I see the difference between 2 commits?
提问by Blankman
I have tried:
我试过了:
git diff sha1 sha2
But the output isn't the best, is it possible to see the difference between 2 commits using gitk?
但是输出不是最好的,是否可以使用 gitk 看到 2 次提交之间的差异?
回答by Mr_and_Mrs_D
In windows at least it is perfectly possible :
至少在 Windows 中,这是完全可能的:
回答by Jens Schauder
Not sure if you actually want a diff or if you want the normal gitk representation but only for the commits leading from sha1
to sha2
不确定您是否真的想要一个差异,或者您是否想要正常的 gitk 表示,但仅适用于从sha1
到的提交sha2
In the later case you can provide all the normal revision parameters: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html
在后一种情况下,您可以提供所有正常的修订参数:https: //www.kernel.org/pub/software/scm/git/docs/gitrevisions.html
So you can do things like
所以你可以做这样的事情
gitk sha1..sha2
or if master got merged into the sha2
branch and you don't want to see the commits that come from master and sha1
, is the first commit branched from master
use
或者,如果 master 合并到sha2
分支中,并且您不想看到来自 master 的提交,并且sha1
, 是从master
use分支的第一个提交
gitk master..sha2
回答by John Szakmeister
Unfortunately, gitk
doesn't support diff output in that way. :-( You can use git difftool
though. It comes with support for a number of tools builtin. For instance, you could do git difftool -t kdiff3 sha1 sha2
. It shows the file diffs one at a time. There was talk on the git list about supporting more than just one file at a time via a diff tool, but I'm not sure where that ended up. I haven't seen a patch implementing it yet.
不幸的是,gitk
不支持这种方式的差异输出。:-(你可以使用git difftool
。它支持许多内置工具。例如,你可以这样做git difftool -t kdiff3 sha1 sha2
。它一次显示一个文件差异。在git列表上有关于支持多个文件的讨论一次通过 diff 工具,但我不确定结果如何。我还没有看到补丁实现它。
回答by Benubird
No, but you can do it using meld:
不,但您可以使用 meld 来做到这一点:
git checkout sha1
git reset sha2
git diftool --tool=meld
The trick is, by checking out sha1 and then resetting to sha2, you are making all the differences between them appear to be uncommitted changes. Then meld can use its ability to view uncommited changes, to do a diff of all the files involved at the same time.
诀窍是,通过检查 sha1 然后重置为 sha2,您使它们之间的所有差异看起来都是未提交的更改。然后 meld 可以使用其查看未提交更改的功能,同时对所有涉及的文件进行比较。