我对 GitHub Enterprise 没有任何经验,但我能够对公共存储库执行以下 cURL 请求:
curl https://api.github.com/repos/msbit/tools/git/blobs/a6628025e73c505a07305fd25507d0736725474d
回复如下:
{
"sha": "a6628025e73c505a07305fd25507d0736725474d",
"node_id": "MDQ6QmxvYjEyMzQwMzg5OmE2NjI4MDI1ZTczYzUwNWEwNzMwNWZkMjU1MDdkMDczNjcyNTQ3NGQ=",
"size": 1575,
"url": "https://api.github.com/repos/msbit/tools/git/blobs/a6628025e73c505a07305fd25507d0736725474d",
"content": "IyBUb29scwoKQSBncmFiIGJhZyBvZiBCYXNoIHNjcmlwdHMgdGhhdCBJIGhh\ndmUgdXNlZCBvZnRlbiBlbm91Z2ggdG8gZmluZCBzZW1pLXVzZWZ1bAoKIyMg\nQmFja3VwIEFQSwoKICAgIGJhY2t1cC1hcGsuc2gKCkJhY2t1cCBhbGwgQVBL\nIGZpbGVzIGZyb20gYW4gYXR0YWNoZWQgQW5kcm9pZCBkZXZpY2UuCgojIyBC\ndW5kbGUgVXBkYXRlcwoKICAgIGJ1bmRsZS11cGRhdGVzLnNoCgpSdW4gQnVu\nZGxlIHVwZGF0ZSBpbiBhIFJ1YnkgcHJvamVjdCwgZGV0ZXJtaW5lIHRoZSBh\ncHByb3ByaWF0ZSBkaXJlY3QgYW5kIHRyYW5zaXRpdmUgZGVwZW5kZW5jaWVz\nLCBhbmQgYWRkIGEgR2l0IGNvbW1pdCB3aXRoIGEgY29ycmVzcG9uZGluZyBt\nZXNzYWdlLgoKIyMgRmV0Y2ggQXBwbGUgRXZlbnQKCiAgICBmZXRjaC1hcHBs\nZS1ldmVudC5zaAoKRG93bmxvYWQgYWxsIFRTIGZpbGVzIGZvciBhIHNwZWNp\nZmllZCBBcHBsZSBldmVudCBhbmQgY29uY2F0ZW5hdGUgdGhlbSB1c2luZyBG\nRm1wZWcuCgojIyBKS1MgdG8gQ1JUIEtleQoKICAgIGprcy10by1jcnQta2V5\nLnNoCgpFeHRyYWN0IGEgc3BlY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zL3BhY2thZ2VzIHJlbW92ZWQuCgojIyBV\ncGRhdGUgRHJ1cGFsCgogICAgdXBkYXRlLWRydXBhbC5zaAoKUGVyZm9ybSBh\nbiBhcHByb3ByaWF0ZSBzZXF1ZW5jZSBvZiBgZHJ1c2hgIGNvbW1hbmRzIHRv\nIHByb3Blcmx5IHVwZGF0ZSBEcnVwYWwuCgojIyBWZXJzaW9uIEFQSwoKICAg\nIHZlcnNpb24tYXBrLnNoCgpQcmludCBvdXQgdGhlIHBhY2thZ2UsIHZlcnNp\nb24gYW5kIHZlcnNpb24gY29kZSBvZiBhIHNwZWNpZmllZCBBUEsgZmlsZS4K\n",
"encoding": "base64"
}
所以也许您正在寻找的 URL 的路径应该是(删除/api/v3
部分):
https://MYDOMAIN/repos/MYOWNERNAME/MYREPOSITORY/git/blobs/{file sha value}