How to Download Files and Folders From GitHub?
Cloning a GitHub repository to your local system is perhaps the most straightforward way to get the source code files.
But you may not always want to clone a repo just to download a few files from GitHub.
There are multiple ways to download files from GitHub depending upon what you want to download:
- Download the entire source code repository in zip format from GitHub website
- Download a single file from GitHub repo
- Download a folder from GitHub (using a web tool)
- Download selected files and folders (using a browser extension)
Let me show all the above use cases in detail.
Download entire GitHub repo (without cloning it)
It's simple, just open the Repository, and you will see a <> Code
button. When you click on it, you'll see different options.
Click on the Download ZIP
button and the entire repository will be downloaded as a ZIP file.
That's neat. How about getting a single file from GitHub? Not too complicated either.
Download a single file from GitHub
Go to the File in the repository.
You can click the file (if you see it). You may also use the Go to File
button on the front page of the repo to quickly search the file.
Once you have opened the individual file, click on the Download Raw File button on the top right (see the image below)
And the file will be downloaded on your system.
Nice, isn't it? Let's see about downloading a single folder from GitHub.
Download a specific folder from a GitHub repository
Go to the folder in the repository that you want to download.
Copy the URL path of that GitHub repo folder. It should look something like this: https://github.com/username/Repo-Name/tree/main/folderName
Go to download-directory.github.io and paste the URL and press Enter:
That's it! Your Folder will be downloaded in zip format. You can see the status of generating the zip file and the final download status.
Ah, it feels so good to see that our Open-Source community has all kinds of hacks and workarounds, doesn't it? βΊοΈ
Download multiple files and folders from GitHub
Sometimes you may not need a whole repo, a folder or a single file, but multiple files probably from multiple locations in the repo.
GitHub doesn't support such a feature officially. However, you can install this browser extension named GitZip. It's Open Source - GitHub Repo.
You can use that tool to select & download multiple files & folders, but they need to be on the same Location/URL. So let's say you want to download the files & folders marked in the image down below -
Simply hover over those files/folders and a checkbox will appear, select your desired ones and you will see a Download button appear at the left bottom, click on that and the selected files/folders will be downloaded.
In the end...
There are many web tools that allow you to download an entire GitHub repo or part of it.
Personally, I prefer using the official GitHub website for downloading the repository or a file. But it's good to see various open source tools to help you download folders, too.
Keep learning, keep coding, keep GitHubing π