1

This link is showing how to use curl to fetch a raw file from private repository with an access token. What is the URL to use to fetch a file with a specific SHA1 hash from a private repository? Can I specify both the repo hash as well as the blob hash?

Thanks in advance

Claudiu Guiman
  • 837
  • 5
  • 18
Uri
  • 479
  • 1
  • 4
  • 10
  • Please clarify your question and provide a code snippet with the problem you're facing. – Claudiu Guiman Nov 05 '19 at 15:49
  • The linked example is showing the command: `curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path` Instead of **repo/content/path** I'd like to provide a hash value so I can retrieve the version which was the latest at that time – Uri Nov 05 '19 at 22:39

1 Answers1

0

You can specify an arbitrary commit hash with the ref parameter, but you cannot specify a blob hash instead of a file path. The reason is that filters and other attributes can be applied to files in the repository, and the path is needed to determine the appropriate content. The same blob located at different paths could be filtered differently, so a blob isn't sufficient to determine the correct contents.

If you need to fetch the raw contents of the blob without filtering or other attributes being applied, then you'll need to clone the repository.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • I assume that by `ref` is actually meant `repo` Thanks – Uri Nov 06 '19 at 00:42
  • No, by `ref` I mean the `ref` parameter which describes an arbitrary revision specification as in [the documentation](https://developer.github.com/v3/repos/contents/#get-contents). Repositories themselves don't have hashes. – bk2204 Nov 06 '19 at 00:48