Bootstrap FreeKB - GitHub - Download a single file from GitHub
GitHub - Download a single file from GitHub

Updated:   |  GitHub articles

There are a number of different ways to download one or more files from Git or GitHub.

Let's say you have the following file in one of your public GitHub repos.

https://github.com/JohnDoe/myrepo/blob/main/example.txt

 

This file can be downloaded by replacing github.com with raw.githubusercontent.com and removing /blob from the URL, thus the URL to download the file would be.

https://raw.githubusercontent.com/JohnDoe/myrepo/main/example.txt

 

For example, on a Linux system, wget could be used to download this file.

wget https://raw.githubusercontent.com/JohnDoe/myrepo/main/example.txt

 

If the file is in a private repository, you will need to generate a Personal Access Token. At https://github.com, select your profile > Settings > Developer Settings > Personal access tokens > Fine-granted tokens and generate your Personal Access Token. And then include Authorization header Token, perhaps something like this if using curl.

curl --header "Authorization: Token <your personal access token>" https://raw.githubusercontent.com/JohnDoe/myrepo/main/example.txt

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f98df6 in the box below so that we can be sure you are a human.