# Git Sparse Checkout Clone only a specific subdirectory without downloading the full repository: ```bash git clone -n --depth=1 --filter=tree:0 <repo-url> cd <repo> git sparse-checkout set --no-cone /path/to/subdir git checkout ``` - `--filter=tree:0` — skip downloading tree objects; only fetch what's needed - `--no-cone` — use path pattern mode (simpler than cone mode for arbitrary paths) - Available since Git 1.7 (sparse checkout) / Git 2.22+ (sparse-checkout command) > Note: the full `.git` metadata is still downloaded. Only working tree files are filtered. ## Revert uncommitted changes in a subdirectory ```bash git checkout some/path/ git checkout file.txt ``` ## Links - [Stack Overflow — Checkout subdirectories in Git](https://stackoverflow.com/questions/180052/checkout-subdirectories-in-git) - [Stack Overflow — Clone a subdirectory only](https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934)