Skip to content
Versora

Manual

Repository

Sparse checkout

3 min read

On this page

In a very large repository (a monorepo with dozens of projects, for example), you rarely need every folder. Sparse checkout keeps only the chosen folders in the working directory. The history and the branches stay complete. The unchecked folders just stop taking up disk space and showing up in searches, and status, checkout and the file watcher get lighter.

Versora uses Git's folder mode (cone mode). Two rules apply in it:

  • loose files at the root always stay;
  • a folder's files stay when the folder is checked or has a checked subfolder.

Choosing the folders

Where to find it

  • Left panel, at the bottom of the list of sections: the SPARSE CHECKOUT row (tooltip "Choose which folders stay in the working directory (sparse checkout)"). With sparse checkout on, it shows "N folders" or "on".
  • Repository bar, with sparse checkout on: "Sparse checkout · N folders" (or "Sparse checkout · custom patterns") and the Configure… button
  • Optimize repository screen, under "Other suggestions": Open sparse checkout, when the repository has many files.

Step by step

  1. Open the Sparse checkout screen. The top shows the state:
    • "Off — all folders are in the working directory.";
    • "On — N folders included." (or "0 folders included (root files only).");
    • "On — with custom patterns (non-cone mode), which this screen doesn't edit."
  2. In the folder tree, check the ones you want in the working directory. With sparse checkout off, all of them come checked: uncheck the ones you don't want. A folder with only some of its subfolders checked shows partial. The arrow next to each folder collapses and expands the subfolders.
  3. To find a folder, type in Filter folders. Select all and Clear all apply to the list.
  4. The footer counts "N folders checked" and "‹x› of ‹y› repository folders stay complete".
  5. Click Turn on and apply (with sparse checkout off) or Apply selection (with it on). The button is disabled when there's nothing to change: "Uncheck the folders you don't want in the working directory" (sparse checkout off and everything checked) or "This selection is already applied".
  6. The notice confirms, for example, "Sparse checkout applied: 3 folders selected."
OptionWhat it doesDefault
Folder treeFolders that stay in the working directory (cone mode).The folders of the current selection; all checked with sparse checkout off
Turn on and apply / Apply selectionApplies the selection.—
Download everything againTurns off sparse checkout: all folders come back.—

What Versora does in git

bash
# the chosen folders go through standard input, one per line
git sparse-checkout set --cone --stdin

Git removes the files outside the selection from the working directory and brings in the ones that were added. No commit, branch or history change happens.

How to undo

Sparse checkout doesn't change branches, tags or HEAD, so it isn't part of Ctrl+Z. To go back, apply the previous selection again or use Download everything again.

Caveats and messages

  • Folders being removed have local changes: "N files with uncommitted changes are outside the selection: ‹files›. Git doesn't delete these files: they stay on disk with their changes, but outside the sparse checkout until you commit or discard them." Click Apply anyway to continue, or go back and commit first.
  • "Kept on disk because of local changes: ‹files›", "Folders kept because they contain untracked files: ‹folders›" and "Folders Git doesn't empty (submodules stay on disk): ‹folders›": Git didn't delete these folders, and the final notice says which ones they are.
  • "Current patterns: ‹patterns›. Applying a selection here switches the repository to folder mode (cone) and replaces these patterns.": the repository used custom patterns, made on the command line. The screen doesn't edit them; applying a selection replaces them.
  • "This repository has no folders in the current commit: there's nothing to choose."
  • "Folder list truncated (very large repository).": use the filter to find the folders.

Downloading everything again

Where to find it

Sparse checkout screen, with sparse checkout on: the Download everything again button (tooltip "Turns off sparse checkout (git sparse-checkout disable): all files come back").

What Versora does in git

bash
git sparse-checkout disable

The final notice is "Sparse checkout turned off: all folders are back in the working directory."

There's no setting of its own. For large repositories, combine sparse checkout with partial clone and with the recommendations in Optimize repository.

See also