How to Use Sparse Git Checkout to Clone AI-For-Beginners Without Translations
Use git clone --filter=blob:none --sparse followed by git sparse-checkout set --no-cone '/*' '!translations' '!translated_images' to download only the core Microsoft AI curriculum while excluding the 50+ language translation folders that bloat the repository size.
The microsoft/AI-For-Beginners repository contains a comprehensive artificial intelligence curriculum with Jupyter notebooks, Python scripts, and a Vue.js quiz application. However, it also ships with extensive translation assets across more than 50 languages stored in translations/ and translated_images/ directories. Using sparse git checkout allows you to fetch only the essential learning materials while skipping the bandwidth-heavy translation payload, as officially documented in the repository's README.md at lines 31-40.
Why Exclude Translations from the Clone?
The AI-For-Beginners repository includes localized content for dozens of languages, dramatically increasing the repository size and clone time. These assets reside primarily in two locations:
translations/– Contains markdown files and notebooks translated into various languagestranslated_images/– Houses localized screenshots and diagrams
For developers who only need the English curriculum or want to minimize disk usage and network bandwidth, downloading these folders is unnecessary. The core curriculum—including all lessons, labs, and the quiz application—functions independently of these translation trees.
The Sparse Git Checkout Solution
Git's sparse checkout feature enables partial working directories, allowing you to specify exactly which paths to populate while leaving others untracked. When combined with blob filters, this approach downloads only the commit history initially, fetching file contents on demand.
The repository's README.md explicitly recommends this method for users who prefer a lightweight local clone. The technique relies on three key Git mechanisms:
--filter=blob:none– Downloads commit history without file contents, deferring blob downloads until files are actually accessed--sparse– Initializes the repository in sparse-checkout mode--no-cone– Enables pattern matching mode that allows exclusion patterns (negations) using the!prefix
Step-by-Step Implementation
Clone the Repository (Bash/macOS/Linux)
Run these commands in your terminal to create a minimal working copy:
# Clone without downloading file blobs
git clone --filter=blob:none --sparse https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners
# Configure sparse checkout to exclude translation directories
git sparse-checkout set --no-cone '/*' '!translations' '!translated_images'
Clone the Repository (Windows CMD)
For Windows Command Prompt users, use double quotes for pattern arguments:
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"
Verify the Sparse Checkout
Confirm that translation folders are excluded by listing top-level directories:
ls -d */ | grep -v translations
You should see lessons/, etc/, and other core directories, but no translations/ or translated_images/ folders. The working copy now contains approximately the minimal set of files needed to run the curriculum.
Understanding the Sparse Checkout Patterns
The command git sparse-checkout set --no-cone writes patterns to .git/info/sparse-checkout, a generated file that controls which paths Git populates in your working directory.
The pattern syntax used here includes:
/*– Include all files and folders at the repository root!translations– Exclude the translations directory and all its contents!translated_images– Exclude the translated images directory
The --no-cone flag is critical because it enables the exclusion syntax (!). Without this flag, Git uses "cone mode," which only supports recursive directory patterns and does not allow negations.
Managing Excluded Content Later
If you later decide you need a specific language translation, you can selectively add it back without recloning the entire repository:
git sparse-checkout add translations/zh-CN
This command updates your sparse-checkout patterns to include the specified path while maintaining exclusions for other translation folders. Git will then fetch the necessary blobs for that specific translation on demand.
What You Get After Sparse Checkout
After completing the sparse checkout, your local copy contains all essential curriculum components:
lessons/– The core Jupyter notebooks, Python scripts, and lab exercisesetc/quiz-app/– The standalone Vue.js quiz applicationenvironment.yml– Conda environment specification with Python dependenciesREADME.md– Documentation and course overview
The working copy excludes only the translation assets, leaving you with a development-ready environment suitable for local execution, GitHub Codespaces, or CI/CD pipelines.
Summary
- Sparse git checkout with
--filter=blob:noneand--sparsecreates a lightweight clone by deferring file downloads and excluding specific directories. - Pattern syntax using
--no-conewith/*and!translationsincludes the core curriculum while excluding 50+ language translation folders. - Verification confirms the absence of
translations/andtranslated_images/directories while preservinglessons/andetc/quiz-app/. - Selective addition via
git sparse-checkout addallows retrieving specific translations later without full reclone.
Frequently Asked Questions
What is sparse git checkout and how does it reduce clone size?
Sparse git checkout is a Git feature that allows you to populate only specific directories of a repository's working tree while leaving others untracked. When combined with --filter=blob:none, Git downloads only the commit history initially, fetching actual file contents (blobs) only when accessed or when directories are explicitly included via sparse-checkout patterns.
Why does the AI-For-Beginners repository need sparse checkout?
The repository contains translation assets for over 50 languages in translations/ and translated_images/ directories, which significantly increase repository size and clone time. Sparse checkout allows learners to download only the English curriculum and core code, reducing bandwidth usage and disk space requirements while maintaining full functionality of the Jupyter notebooks and quiz application.
Can I access translations later if I clone without them?
Yes, you can selectively add specific translations later using git sparse-checkout add translations/[language-code], such as git sparse-checkout add translations/zh-CN for Simplified Chinese. This updates your sparse-checkout patterns to include only the requested translation, and Git fetches the necessary files on demand without requiring a full repository reclone.
Does sparse checkout affect the functionality of the curriculum notebooks?
No, the core curriculum in the lessons/ directory and the quiz application in etc/quiz-app/ function identically regardless of whether translations are present. All Python dependencies specified in environment.yml and the notebook code references remain valid, as the curriculum code has no dependencies on the translation assets stored in separate directories.
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 →