• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

How to load single files from a Github repository

AnonyViet by AnonyViet
January 24, 2023
in Tips
0

While Github is most commonly used for hosting large code projects, it also acts as a pretty good FIle host and sometimes you just want to download a file or two without having to download the whole thing. what about the repo? Fortunately, Github supports this by web and command line.

Join the channel Telegram of the AnonyViet 👉 Link 👈

How to load single files from a Github repository

Download a Single File from Github

If you prefer to use a web browser, you can download any file pretty easily. Go to the File you want to download and click “Raw:”

How to load single files from a Github 3 . repository

This will open a page with a direct link to File. You can copy, but in most browsers, you can right-click and select “Save As” to download the File directly.

How to load single files from a Github 4 . repository

For cpde files, the downloaded file can be saved as a .txt, you will need to manually edit the file extension before or after downloading.

Download Single File from Command Line

Files are provided from raw.githubusercontent.com, can be downloaded directly via wget or curl. They are stored in accessible locations, so if you know the username, repository and File path, you can download any File on any branch like this:

wget https://raw.githubusercontent.com/username/repository/branch/path/filename.md

If you want to use Git’s API, you can interact with it more directly and download files when you are unsure of the exact File location. You will need to generate a personal access token to use the API and replace “ACCESS_TOKEN” in this script.

curl -H 'Authorization: token ACCESS_TOKEN ' -H \
'Accept: application/vnd.github.v3.raw' -O -L \
https://api.github.com/repos/username/repository/contents/path/filename.md

/repos/{user}/{repo}/contents endpoint will do different things depending on whether the path points to a directory or a File. If it’s a File, it will return that File’s metadata:

{
  "type": "file",
  "encoding": "base64",
  "size": 5362,
  "name": "README.md",
  "path": "README.md",
  "content": "encoded content ...",
  "sha": "3d21ec53a331a6f037a91c368710b99387d012c1",
  "url": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
  "git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
  "html_url": "https://github.com/octokit/octokit.rb/blob/master/README.md",
  "download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/README.md",
  "_links": {
    "git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
    "self": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
    "html": "https://github.com/octokit/octokit.rb/blob/master/README.md"
  }
}

If it’s a directory, it will return all files and subdirectories in an array:

[
  {
    "type": "file",
    "size": 625,
    "name": "octokit.rb",
    "path": "lib/octokit.rb",
    "sha": "fff6fe3a23bf1c8ea0692b4a883af99bee26fd3b",
    "url": "https://api.github.com/repos/octokit/octokit.rb/contents/lib/octokit.rb",
    "git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/fff6fe3a23bf1c8ea0692b4a883af99bee26fd3b",
    "html_url": "https://github.com/octokit/octokit.rb/blob/master/lib/octokit.rb",
    "download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/lib/octokit.rb",
    "_links": {
      "self": "https://api.github.com/repos/octokit/octokit.rb/contents/lib/octokit.rb",
      "git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/fff6fe3a23bf1c8ea0692b4a883af99bee26fd3b",
      "html": "https://github.com/octokit/octokit.rb/blob/master/lib/octokit.rb"
    }
  },
  {
    "type": "dir",
    "size": 0,
    "name": "octokit",
    "path": "lib/octokit",
    "sha": "a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
    "url": "https://api.github.com/repos/octokit/octokit.rb/contents/lib/octokit",
    "git_url": "https://api.github.com/repos/octokit/octokit.rb/git/trees/a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
    "html_url": "https://github.com/octokit/octokit.rb/tree/master/lib/octokit",
    "download_url": null,
    "_links": {
      "self": "https://api.github.com/repos/octokit/octokit.rb/contents/lib/octokit",
      "git": "https://api.github.com/repos/octokit/octokit.rb/git/trees/a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
      "html": "https://github.com/octokit/octokit.rb/tree/master/lib/octokit"
    }
  }
]

Then you can use a JSON parser like jq to split the URL and download it. To get the list of repo files recursively, you need to fetch root tree. You can also use github to create a simple website in 15 minutes here.

The article achieved: 5/5 – (100 votes)

Tags: filesGithubloadrepositorysingle
Previous Post

What is CTF? If you want to be a Hacker, should you play CTF?

Next Post

Lesson 170: How to calculate compound interest in Excel

AnonyViet

AnonyViet

Related Posts

How to encrypt messages with GenZ’s smiley face icon
Tips

How to encrypt messages with GenZ’s smiley face icon

July 10, 2026
Download the Copyright-Free Music app for Cafes now
Tips

Download the Copyright-Free Music app for Cafes now

July 9, 2026
Multcloud – Manage, copy, and move data between Cloud Drives
Tips

Multcloud – Manage, copy, and move data between Cloud Drives

July 9, 2026
9 Best and Easy to Use Video Editing Software
Tips

9 Best and Easy to Use Video Editing Software

July 8, 2026
11 reasons you should buy a Windows Laptop instead of a Macbook
Tips

11 reasons you should buy a Windows Laptop instead of a Macbook

July 7, 2026
The easiest way to convert Word File to PowerPoint – Convert DOCX File to PTTX
Tips

The easiest way to convert Word File to PowerPoint – Convert DOCX File to PTTX

July 6, 2026
Next Post
Lesson 170: How to calculate compound interest in Excel

Lesson 170: How to calculate compound interest in Excel

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Learn new skills with iPad 11 (A16) 128GB: when is enough, when should you upgrade to a higher level?

Learn new skills with iPad 11 (A16) 128GB: when is enough, when should you upgrade to a higher level?

July 10, 2026
Instructions on how to draw on Note macOS 27 are extremely convenient

Instructions on how to draw on Note macOS 27 are extremely convenient

July 10, 2026
How to encrypt messages with GenZ’s smiley face icon

How to encrypt messages with GenZ’s smiley face icon

July 10, 2026
Download the Copyright-Free Music app for Cafes now

Download the Copyright-Free Music app for Cafes now

July 9, 2026
Learn new skills with iPad 11 (A16) 128GB: when is enough, when should you upgrade to a higher level?

Learn new skills with iPad 11 (A16) 128GB: when is enough, when should you upgrade to a higher level?

July 10, 2026
Instructions on how to draw on Note macOS 27 are extremely convenient

Instructions on how to draw on Note macOS 27 are extremely convenient

July 10, 2026
How to encrypt messages with GenZ’s smiley face icon

How to encrypt messages with GenZ’s smiley face icon

July 10, 2026
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

Learn new skills with iPad 11 (A16) 128GB: when is enough, when should you upgrade to a higher level?

Learn new skills with iPad 11 (A16) 128GB: when is enough, when should you upgrade to a higher level?

July 10, 2026
Instructions on how to draw on Note macOS 27 are extremely convenient

Instructions on how to draw on Note macOS 27 are extremely convenient

July 10, 2026
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply