# How to Configure Sparse Git Checkout to Exclude Large Translation Folders During Clone

> Clone Microsoft AI For Beginners skipping large translation folders with sparse git checkout. Use git clone --filter and git sparse-checkout set commands for efficient cloning and reduced download size.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: how-to-guide
- Published: 2026-08-27

---

**Use `git clone --filter=blob:none --sparse` followed by `git sparse-checkout set --no-cone '/*' '!translations' '!translated_images'` to clone the microsoft/AI-For-Beginners repository without downloading the 50+ language translation directories.**

The **microsoft/AI-For-Beginners** repository bundles extensive multilingual curriculum materials that can significantly inflate the clone size. When you configure sparse git checkout to exclude large translation folders during clone, you retrieve only the core Jupyter notebooks, Python scripts, and quiz applications while skipping the heavy `translations/` and `translated_images/` directories.

## Why Exclude Translation Folders?

The repository structure includes a top-level `translations/` directory containing localized content for more than 50 languages, each accompanied by assets in `translated_images/`. These folders are redundant for developers working exclusively with the English curriculum or a single target language. By leveraging Git’s sparse checkout feature, you reduce bandwidth usage and local disk consumption while maintaining full access to the repository’s commit history and branching capabilities.

## Prerequisites

This workflow requires **Git 2.25 or later**, which introduced the modern `sparse-checkout` command with cone mode support. Verify your version with:

```bash
git --version

```

## Step-by-Step Sparse Checkout Configuration

Follow these steps to clone the repository while filtering out the translation directories.

### 1. Perform a Partial Clone with Blob Filtering

Start by creating a shallow, filter-enabled clone that downloads only commit metadata, deferring file content (blobs) until needed:

```bash
git clone --filter=blob:none --sparse https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners

```

The `--filter=blob:none` flag prevents Git from fetching file contents immediately, while `--sparse` automatically enables sparse-checkout mode in the new repository.

### 2. Initialize Sparse Checkout Mode

Initialize the sparse-checkout configuration to control which paths populate your working tree:

```bash
git sparse-checkout init --cone

```

The `--cone` flag enables a simplified pattern mode. While optional, initialization prepares the repository for pattern-based filtering. You will override the cone mode setting in the next step to use explicit exclusion patterns.

### 3. Define Include and Exclude Patterns

Specify that you want everything in the repository root **except** the translation directories:

```bash
git sparse-checkout set --no-cone '/*' '!translations' '!translated_images'

```

This command uses the `--no-cone` flag to allow negation patterns. The syntax `'/*'` includes all files and folders at the repository root, while `'!translations'` and `'!translated_images'` explicitly exclude those directories.

### 4. Verify the Resulting Repository Structure

Confirm that Git has populated only the desired paths:

```bash
git status
ls

```

You should see the core curriculum directories—such as `lessons/`, `etc/`, and `.github/`—while the `translations/` and `translated_images/` folders remain absent from your working tree.

## Understanding the Pattern Syntax

The sparse checkout system supports two pattern modes:

- **Cone mode** (default): Optimized for directories, using simple path prefixes. Best for monorepos with clean directory boundaries.
- **No-cone mode**: Supports POSIX glob patterns including negation (`!`), allowing fine-grained inclusion and exclusion rules.

When you configure sparse git checkout to exclude large translation folders during clone, the `--no-cone` flag is essential because it permits the exclusion patterns (`!translations`) that block the heavy directories while preserving everything else.

## Repository Documentation Sources

The sparse checkout workflow is officially documented in the repository’s [`README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/README.md) file. According to the source at line 33, the English README states:

> “This repository includes 50+ language translations which significantly increases the download size. To clone without translations, use sparse checkout.”

Each localized README repeats this guidance for non-English speakers. For example, the Vietnamese translation at [`translations/vi/README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/translations/vi/README.md) (line 33) provides the same instructions:

> “Kho lưu trữ này bao gồm hơn 50 bản dịch ngôn ngữ làm tăng đáng kể dung lượng tải xuống. Để nhân bản mà không tải các bản dịch, hãy sử dụng sparse checkout.”

These references confirm that sparse checkout is the recommended approach for lightweight clones of this educational repository.

## Summary

- The **AI-For-Beginners** repository contains 50+ translation folders that bloat the clone size significantly.
- Use **`git clone --filter=blob:none --sparse`** to initialize a clone without downloading translation assets immediately.
- Run **`git sparse-checkout set --no-cone '/*' '!translations' '!translated_images'`** to exclude the heavy directories while keeping core curriculum files.
- Verify exclusion with `git status` and `ls` before beginning development.
- This method requires **Git 2.25+** and is officially documented in [`README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/README.md) and all language-specific README files under `translations/`.

## Frequently Asked Questions

### What Git version is required for sparse checkout?

Sparse checkout requires **Git 2.25 or later**, which introduced the `sparse-checkout` subcommand and modern cone/no-cone pattern syntax. Earlier versions lack support for the `--cone` and `--no-cone` flags.

### Will sparse checkout affect my ability to switch branches?

No. Sparse checkout operates on the working tree only. You retain full access to all branches and commit history. When you switch branches, Git updates only the files permitted by your sparse-checkout patterns, keeping the translation directories excluded regardless of branch state.

### Can I add translation folders later if I need them?

Yes. Update your sparse-checkout patterns using `git sparse-checkout set` with adjusted rules. For example, run `git sparse-checkout set --no-cone '/*' '!translations/es' '!translated_images'` to exclude all translations except Spanish, or remove the negation entirely to populate all directories.

### Does `--filter=blob:none` prevent me from viewing file contents?

No. The `blob:none` filter defers downloading file contents until you actually need them. When you check out a file or switch to a commit containing new files, Git fetches the blobs automatically on demand. This lazy-loading strategy reduces initial clone time and storage usage without breaking functionality.