How to Use Git Sparse Checkout to Clone the AI-For-Beginners Repo Without 40+ Language Translations
Git sparse checkout with --filter=blob:none allows you to clone only the core English curriculum from the microsoft/AI-For-Beginners repository while excluding the translations/ and translated_images/ directories, reducing the download from several gigabytes to a few hundred megabytes.
The microsoft/AI-For-Beginners repository hosts a comprehensive artificial intelligence curriculum alongside localization assets for over 40 languages. While these translations make the course accessible globally, they dominate the repository size—often exceeding 4 GB—which makes full clones slow and bandwidth-intensive. Using sparse checkout, you can download only the lesson content and code examples you need while preserving full access to the commit history.
Why the AI-For-Beginners Repository Needs Sparse Checkout
The Translation Size Problem
According to the repository's source code, the translations/ directory contains more than 40 language-specific folders, while translated_images/ stores pre-generated PNG assets for localized notebooks. These directories constitute the majority of the repository's storage footprint. The project's README.md explicitly addresses this issue at lines 33-40, providing sparse checkout instructions to help users bypass unnecessary localization files. The same pattern appears in every language-specific README inside translations/*, such as translations/zh-TW/README.md at lines 36-40.
How Git Sparse Checkout Works
Partial Clone with --filter=blob:none
Git 2.25 and later supports partial clones that fetch only the commit graph and tree objects without immediately downloading file contents (blobs). When you execute git clone --filter=blob:none --sparse, Git retrieves the metadata required to browse the repository structure but defers downloading actual file data until it matches your sparse-checkout patterns.
Pattern-Based Filtering with .git/info/sparse-checkout
The git sparse-checkout set command writes include and exclude patterns to .git/info/sparse-checkout in your local repository. This configuration file determines which files Git materializes in your working tree. When you specify !translations and !translated_images, Git marks those subtrees as excluded, ensuring their blobs are never fetched from the remote even when you switch branches.
Step-by-Step Implementation
Cloning on Unix, macOS, and Linux
Run the following commands in your terminal to clone only the core curriculum:
# Clone the repo with filtered blobs and enable sparse checkout
git clone --filter=blob:none --sparse https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners
# Keep everything except the translations and their images
git sparse-checkout set --no-cone '/*' '!translations' '!translated_images'
Cloning on Windows Command Prompt
For Windows CMD, use double quotes instead of single quotes:
git clone --filter=blob:none --sparse https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners
git sparse-checkout set --no-cone "/*" "!translations" "!translated_images"
Managing Your Sparse Checkout
Adding Specific Languages Later
If you later require a specific translation, you can fetch it on demand without recloning the entire repository. For example, to add the Japanese translation:
git sparse-checkout add translations/ja
Git fetches only that folder's blobs, leaving your working tree lightweight while providing access to the requested content.
Verifying Which Files Are Present
To confirm that the heavy directories remain excluded and verify your working tree size:
# Count the number of files currently checked out
git ls-files | wc -l
# List files in the working tree
git status --short
Summary
- The microsoft/AI-For-Beginners repository contains over 40 language translations in
translations/and large image assets intranslated_images/that exceed 4 GB combined. - Sparse checkout with
--filter=blob:nonedownloads only the commit history and metadata initially, fetching file contents only for paths matching your patterns. - The
.git/info/sparse-checkoutfile stores your include/exclude rules, which persist across branch switches and updates. - You can selectively add specific language folders later using
git sparse-checkout addwithout recloning. - This approach is officially documented in the repository's
README.mdat lines 33-40 for both Unix-like systems and Windows.
Frequently Asked Questions
What Git version do I need for sparse checkout?
You need Git 2.25 or later to use the --filter=blob:none option and the modern sparse-checkout interface. Earlier versions lack support for partial clones and the --no-cone pattern syntax required for the exclude patterns used in the AI-For-Beginners documentation.
Can I switch from sparse to full checkout later?
Yes. Run git sparse-checkout disable to materialize all files in the repository, or use git sparse-checkout add to incrementally include additional directories. Git will fetch the necessary blobs on demand when you execute these commands, converting your partial clone into a full checkout gradually.
Does sparse checkout affect the Git history?
No. Sparse checkout affects only your working tree and which blobs are downloaded to your local object database. The commit history remains complete and intact—you can browse all commits, view diffs, and switch branches normally. Only the actual file contents of excluded paths are omitted from your disk until explicitly requested.
Why does the AI-For-Beginners README recommend excluding translated_images?
The translated_images/ directory contains pre-generated PNG assets derived from the lesson notebooks for each supported language. These files are large binary blobs that are unnecessary if you are only reading the English curriculum or generating images locally. Excluding both translations/ and translated_images/ provides the maximum size reduction while preserving all executable code and documentation.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →