read a folder from GitHub using the command line or a browser tool
GitHub does not have a built-in button to read one folder from a repository. The site downloads entire repositories by default. To get just one directory, you have three practical routes: use the command line with Git, use a browser-based tool like DownGit, or manually read the files one by one through GitHub's web interface. The command line method is fastest if you already have Git installed; the browser tool works if you do not want to install anything.
Each method takes a different amount of time and requires different tools. The choice depends on whether you have Git on your computer, how many files are in the folder, and whether you plan to sync changes later.
Key Takeaways
- The command line method using git sparse-checkout downloads only the folder you need and takes about two minutes if Git is already installed.
- DownGit (downgit.github.io) lets you paste a GitHub folder URL and read it as a ZIP file without installing any software.
- Manually downloading files through GitHub's web interface works for small folders but becomes tedious with more than ten files.
- If you plan to pull updates from the repository later, the command line method keeps your folder connected to the original repository.
Using the command line with git sparse-checkout
This method downloads only the folder you want and keeps it connected to the repository so you can pull updates later. Open your terminal or command prompt, navigate to where you want the folder to live, and run these commands in order.
First, create an empty local repository and point it to the GitHub repository:
git init my-folder-name cd my-folder-name git remote add origin https://github.com/username/repository-name.git
Replace my-folder-name with what you want to call the folder on your computer, username with the GitHub account name, and repository-name with the name of the repository. You can copy the repository URL directly from GitHub's green Code button.
Next, configure Git to read only the folder you need:
git config core.sparseCheckout true echo "path/to/folder" >> .git/info/sparse-checkout
Replace path/to/folder with the exact path to the folder inside the repository. If the folder is at the top level and called docs, type docs. If it is nested inside another folder, type parent-folder/docs. You can see the folder structure on GitHub's web interface.
Finally, pull the files:
git pull origin main
If the repository uses master instead of main as the default branch, replace main with master. GitHub shows the default branch name on the repository's home page, usually near the top left.
Using DownGit for a quick browser read
DownGit is a free web tool that converts any GitHub folder into a downloadable ZIP file. Go to downgit.github.io, paste the URL of the folder you want, and click read.
To get the folder URL, open the folder on GitHub, copy the address from your browser's address bar, and paste it into DownGit. The tool generates a ZIP file that you can extract on your computer. This method works on any device with a web browser and does not require Git to be installed.
DownGit works best for folders under 100 files. Larger downloads may time out or fail. If you hit a size limit, the command line method is more reliable.
Manually downloading files through GitHub's web interface
If you have only a few files in the folder, you can read them one at a time through GitHub's website. Open the folder, click on each file, click the Raw button, right-click the page, and select Save As. This method is slow but requires no additional tools or knowledge of the command line.
For folders with more than five or six files, this approach becomes tedious. Use DownGit or the command line instead.
Choosing between the three methods
Use the command line method if you already have Git installed, plan to pull updates from the repository later, or the folder contains more than 50 files. This method is the most flexible and keeps your local folder synced with the original.
Use DownGit if you want the fastest setup, do not have Git installed, or just need a one-time read of a small to medium folder. It requires no installation and works in any browser.
Use manual read only for very small folders with fewer than five files, or if you are unfamiliar with the command line and DownGit is not working.
What to do if the folder path is wrong
If you run the command line method and Git returns an error or downloads nothing, the folder path is likely incorrect. Go back to GitHub, open the folder you want, and check the exact spelling and nesting. Folder names are case-sensitive on GitHub, so Docs is different from docs.
Copy the folder name directly from GitHub rather than typing it from memory. If the folder is nested three levels deep, your path should include all three levels separated by forward slashes: level-one/level-two/level-three.
Keeping your downloaded folder updated
If you used the command line method, you can pull new changes from the repository later by opening the folder in your terminal and running git pull origin main again. This updates only the files that changed, not the entire folder.
If you used DownGit or manual read, you will need to read the folder again to get updates. There is no automatic sync. For repositories you plan to follow over time, the command line method saves work.
Frequently Asked Questions
Can I read a folder from a private GitHub repository?
Yes, but you need authentication. With the command line method, Git will prompt you for your GitHub username and password (or a personal access token if you have two-factor authentication enabled). DownGit does not support private repositories, so use the command line instead.
What if I get an error saying the branch does not exist?
The repository may use a branch name other than main or master. Go to GitHub, click the branch dropdown at the top of the repository, and see what branches are available. Use the correct branch name in your git pull command.
Do I need to install Git to read a folder?
No. DownGit works without Git installed. If you do not have Git and do not want to install it, use DownGit for folders under 100 files, or read files manually for very small folders.
Will downloading a folder create a copy or a shortcut?
It creates a full copy of the folder and its files on your computer. Changes you make locally do not affect the original repository on GitHub. If you used the command line method, you can pull updates from GitHub, but your local edits stay separate.
Can I read just one file instead of a whole folder?
Yes. Open the file on GitHub, click Raw, right-click, and select Save As. Or use DownGit with the direct URL to the file. This is faster than downloading the entire folder if you need only one file.