我希望能够直接从 Linux 内核 GIT 存储库中比较文件/目录,而无需下载完整源代码。
具体来说,我对两种可能的解决方案感兴趣:
- 能够通过网络浏览器 (firefox) 进行比较
- 一个适用于 Ubuntu 的 GUI 实用程序,可以执行远程差异。
- 有关如何设置选项 #2 的教程
编辑
作为我正在寻找的示例,我曾经使用 CrossVC用于 CVS 存储库中的上述任务。
最佳答案
Gitweb kernel.org 允许查看任意提交之间的差异,例如,请参阅以下链接了解 v2.6.32-rc6 和 v2.6.32-rc7 之间的差异:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;hp=refs/tags/v2.6.32-rc6;h=refs/tags/v2.6.32-rc7
(使用 patch 链接获取可以应用的普通补丁),以及文件的任意版本之间/任意文件的任意版本之间,例如:diff to current链接 history查看。
不幸的是,官方 gitweb 版本(与 Git 本身一起分发)和 kernel.org 使用的分支都不会生成任意提交之间的链接,因此您必须手工制作(手动创建)URL 以提供给 gitweb。在commitdiff
的情况下查看(操作)您需要的 iparameters 是 'h'
(哈希)和 'hp'
(散列父级);在 blobdiff
的情况下查看它们是'hb
'(哈希基础)和 'hpb'
(哈希父基),还有 'f'
(文件名)和 'fp
'(文件父级)。
模板
对于两个任意提交之间的差异(相当于命令行中的
git diff A B
)<a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;hp=" rel="noreferrer noopener nofollow">http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;hp=</a><b><i>A</i></b>;h=<b><i>B</i></b>
对于同一文件的两个版本之间的差异(相当于
git diff A B <filename>
)。<a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff;f=" rel="noreferrer noopener nofollow">http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff;f=</a><i><filename></i>;hpb=<b><i>A</i></b>;hp=<b><i>B</i></b>
请注意,核心 gitweb(但目前不是 kernel.org 使用的分支)可以使用 path_info 版本,例如:
<a href="http://repo.or.cz/w/git.git/blobdiff/" rel="noreferrer noopener nofollow">http://repo.or.cz/w/git.git/blobdiff/</a><strong>A</strong>..<strong>B</strong>:/<em><filename></em>
如何找到它
例如在 Web 界面中查找 merge 提交
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=1c5aefb5b12a90e29866c960a57c1f8f75def617例如,查找一个提交和第二个父级之间的差异链接
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/?id=1c5aefb5b12a90e29866c960a57c1f8f75def617&id2=54a217887a7b658e2650c3feff22756ab80c7339将比较提交的 SHA-1 替换为您要比较的修订名称或修订标识符,例如在 v3.15-rc8 和 v3.15-rc7 之间生成差异
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/?id=v3.15-rc8&id2=v3.15-rc7或生成补丁(rawdiff)
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/rawdiff/?id=v3.15-rc8&id2=v3.15-rc7
关于git - 如何直接从 Linux 内核 GIT 存储库中比较文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1737306/