从GITHub commit url

时间:2017-05-16 08:22:50

标签: git github

如果您打开GITHub提交,请点击“已更改的文件”。链接并单击任何一个已更改的文件,浏览器中的提交URL将附加一个diff hash id,如下所示:

'的#DIFF-3db08c3ce067ae92af324b2d8bd6b5e2 '

完整网址 - https://github.com/google/guava/commit/19c39725be34efafa59edf6238713e97f6565eb1#diff-3db08c3ce067ae92af324b2d8bd6b5e2

任何人都可以解释一下这个diff hash id究竟是什么,是否有任何git命令为更改的文件生成此id?

3 个答案:

答案 0 :(得分:1)

The part after #diff- isn't a SHA-1 hash, because it doesn't have 40 characters but rather 32. In fact, if you run this command in your repo:

git rev-parse 3db08c3ce067ae92af324b2d8bd6b5e2

you'll get this:

fatal: ambiguous argument '3db08c3ce067ae92af324b2d8bd6b5e2': unknown revision or path not in the working tree.

So, if I had to guess, I'd say that's a GUID generated by GitHub to keep track of the files included in commit.

答案 1 :(得分:0)

我巧合地问了支持,并且github告诉我这是没有记录的。 我们应该使用某种API来恢复URI。

我不喜欢这个答案,但事实就是如此。

答案 2 :(得分:0)

“ diff-”后的32个字符是路径和文件名的MD5哈希。这是使用node.js的示例:

const crypto = require('crypto');
var hash = crypto.createHash('md5').update(path+'/'+filename).digest('hex');