git 如何用git比较两个标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3211809/
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
How to compare two tags with git?
提问by bsd
I would like to do a diff between two tags and committed changes between those two tags. Could you please tell me the command?
我想在两个标签之间做一个差异,并在这两个标签之间提交更改。你能告诉我命令吗?
回答by gauteh
$ git diff tag1 tag2
or show log between them:
或显示它们之间的日志:
$ git log tag1..tag2
sometimes it may be convenient to see only the list of files that were changed:
有时仅查看已更改的文件列表可能会很方便:
$ git diff tag1 tag2 --stat
and then look at the differences for some particular file:
然后查看某些特定文件的差异:
$ git diff tag1 tag2 -- some/file/name
A tag is only a reference to the latest commit 'on that tag', so that you are doing a diff on the commits between them.
标签只是对“该标签上”最新提交的引用,因此您正在对它们之间的提交进行差异化。
Also, a good reference: http://learn.github.com/p/diff.html
另外,一个很好的参考:http: //learn.github.com/p/diff.html
回答by Nakilon
If source code is on Github, you can use their comparing tool: https://help.github.com/articles/comparing-commits-across-time/
如果源代码在 Github 上,您可以使用他们的比较工具:https: //help.github.com/articles/comparing-commits-across-time/
回答by Tom Howard
For a side-by-side visual representation, I use git difftool
with openDiff
set to the default viewer.
对于并排视觉表示,我将git difftool
withopenDiff
设置为默认查看器。
Example usage:
用法示例:
git difftool tags/<FIRST TAG> tags/<SECOND TAG>
If you are only interested in a specific file, you can use:
如果您只对特定文件感兴趣,可以使用:
git difftool tags/<FIRST TAG>:<FILE PATH> tags/<SECOND TAG>:<FILE PATH>
As a side-note, the tags/<TAG>
s can be replaced with <BRANCH>
es if you are interested in diff
ing branches.
作为旁注,如果您对ing 分支感兴趣,tags/<TAG>
可以将 s 替换为<BRANCH>
es diff
。