HACKER Q&A
📣 999900000999

Getting a single file from a public GitHub repo?


Let's say I have a public GitHub repo called Notes

The entire repo is only a Readme file, and a folder with 20 text files.

Is it possible to list the 20 text files and download one. If possible I'd love to do this via a Rest API, and without cloning the whole repo.


  👤 NonEUCitizen Accepted Answer ✓
For downloading a single file, I do it manually by clicking on the "Raw" button the using Copy/Paste. The raw button leads to a url starting with "https://raw.githubusercontent.com/" If that url is stable, then presumably I could've used wget instead of manual copy/paste.

👤 verdverm
You can get a single file, but you cannot list them, afaik, maybe I'm wrong? Cloning is not that expensive, consider how many deps you fetch in a typical day.

I actually do this to fetch initial / bootstrap content stored in a repo, and hold it in memory without the need to write it. I am considering changing this and exec'n out to git as a more secure / standard practice