Series: Git
Part 9/10Introduction#
In some projects, instead of downloading the entire repository on GitHub, you may need only a specific folder. For example, you might want to take only design files from a large project. In this guide, I'll show you step by step how to do this with the Git Sparse Checkout method ⚡
At the end of this guide:
- You'll be able to download only the folder you want,
- You'll save time and disk space by getting rid of unnecessary files,
- You'll be able to easily apply in Arch Linux and other Linux distributions.
What is Sparse Checkout?#
Git Sparse Checkout is a feature that allows you to pull only specific files or folders from a Git repository instead of the entire repository.
Advantages#
- Reduces download time in large repositories,
- Saves disk space,
- You don't have to deal with unnecessary files.
Step by Step Implementation#
1️⃣ Create a New Folder and Initialize Git#
mkdir pico-v2 && cd pico-v2
git init
2️⃣ Add Remote Repository#
git remote add origin https://github.com/picocss/examples.git
3️⃣ Enable Sparse Checkout#
git config core.sparseCheckout true
4️⃣ Specify the Folder You Want to Download#
echo "v2-sass-customized-design-system/" >> .git/info/sparse-checkout
Attention 💡 The folder path should be written according to the repository root directory.
5️⃣ Download Only the Relevant Folder#
git pull origin master
Branch check ⚠️ If the repository uses the main branch, you should use git pull origin main.
Result#
Now only the folder you need has been downloaded:
pico-v2/v2-sass-customized-design-system/
Summary#
- You can pull only specific folders without downloading the entire GitHub repository.
- Sparse checkout saves time and disk in large projects.
- Can be easily applied on Linux ⚡
Resources#
This feature exists in GitLab UI, why doesn't GitHub UI have it? 🤔

Comments