How can I checkout or download single file from GitHub repo

Hello Everyone,

I am new to GitHub.

We have requirement in our organization where we need to checkout single file (not branch) from GitHub repo and move to target server but I couldn’t see any option to checkout single file.

Can you please suggest if we have any such option and how to do it.




There’s not really a way to do this without git cloneing your entire repo.

If it’s just a single file, you can go to your GitHub repo, find the file in question, click on it, and then click “View Raw”, “Download” or similar to obtain a raw/downloaded copy of the file and then manually transfer it to your target server.

​If there’s anything else I can help you with, let me know; so happy to help further!

Kindest regards,


_ Why you lie? _

Example: Download from master branch on remote repo

git checkout origin/master --

That still requires the repo via clone before you can just checkout individual files.

Probably the easiest way is use wget to pull down the raw file:


Thanks! this was what I was looking for

1 Like
1 Like

Hi ! how can I remove the read only file, in a class ? because I can’t edit the code. Thank you in advance

Might be a noob answer but try to download the files to google colab and move it using shutil.copytree to your Google Drive! Then download the files / subfolders you have and delete the whole thing from your Drive! 

P.S. - Might seem really long but nothing doing if you’re dealing with deep learning trained weights( My file size was around 250mb) so had to do it! :slight_smile:

In case the above steps are not clear , open this notebook on google colab! 

Link to the notebook 

Nah, download as Winzip


it does work and you get your files from link repository but these files turn in encrypted after that, you don’t get the same data from it

What if you wanted to download a single file in a private repo that requires SSO? When I download raw, it has a token query param beside it. How would I download it programatically?

1 Like

You can use the API, see Get repository content. For a private repository you have to authenticate the request using a suitable token (PAT or OAuth).

Your request should look something like this:

curl -H "Authorization: token ${TOKEN}" -H "Accept: application/vnd.github.v3+json"{user}/{repo}/contents/{path}
1 Like

You could also use curl (instead of wget) with the -o option to specify the output:


curl -o ~/Desktop/filename.ext

If you just want to download the file you can right-click the Raw link and click Save Link As…: