Repository
Optimize repository
7 min read
A large repository slows down little by little: git status takes longer, the graph takes a while
to open, the .git folder grows. The Optimize repository screen measures the repository,
explains what weighs it down and offers Git's own maintenance tasks that fix each case. Nothing runs
without your confirmation, and you see the exact commands beforehand.
Everything is local to the repository: the settings go to its .git/config and the tasks are
one-off git maintenance run --task=… runs. The app never uses git maintenance start or
register, which would create tasks in the Windows Task Scheduler and write to the global
configuration.
- Tab menu (right-click the repository tab): Optimize repository…
- Palette (Ctrl+P): "Optimize repository…" (detail: "Diagnosis, Git maintenance and status caches for large repositories"). While the repository is loading, the command is unavailable ("the repository is still loading").
- Open the screen. It shows "Analyzing the repository…" ("Counting objects, refs and files and timing git status. On a large repository this takes a few seconds.").
- Read the numbers, the settings and the recommendations (described below).
- Check the recommendations you want to apply and click Apply N recommendations….
- Review the commands in the Confirm optimization window and click Apply.
- Follow "Command N of M". To stop, click Cancel.
- See the Optimization result, with Before and after.
The footer shows "Diagnosed in ‹time› · Git ‹version›" and the Diagnose again button.
| Block | Rows |
|---|---|
| Objects | Objects, In packs, Packs (count and size), Loose objects, "Loose, already packed", Stray files |
| Refs | Local branches, Remote branches, Tags, Other, Loose refs (or "reftable format") |
| History | Commits, commit-graph (how many commits it covers, "not written" or "(N missing)"), Multi-pack index ("yes" or "no") |
| Files | Tracked, Untracked |
At the end, Output of git count-objects -vH shows Git's text, as Git wrote it.
The Repository settings block shows the settings that matter most day to day and where each value comes from ("this repository", "this worktree", "global config", "system config", "command line" or "other source"):
| Key | What it shows |
|---|---|
core.fsmonitor | on, off or not set; "watching the folder" when the process is running; "not available here (…)" with the reason: "Windows and macOS only", "requires Git 2.37 or newer" or "network folder" |
core.untrackedCache | on, off or not set |
feature.manyFiles | the value, with the note "Not recommended by the app: it changes the index format (version 4, no checksum), which older libgit2-based tools can't read." |
core.commitGraph | on, off or not set |
core.multiPackIndex | on, off or not set |
With fsmonitor or the untracked cache on, the Turn off… button appears, which goes through the same confirmation.
The app only recommends what's worth it for the repository's size. With nothing to do, it says "Nothing to recommend: the repository is already in good shape for its size." Each recommendation explains why with the repository's numbers.
| Recommendation | When it appears | Commands | Checked by default |
|---|---|---|---|
| Turn on Git's fsmonitor (core.fsmonitor) | 10,000 tracked files or more, or a slow git status (400 ms or more with 2,000 files or more), and the value isn't set | git config --local core.fsmonitor true | Yes |
| Turn on the untracked files cache (core.untrackedCache) | 5,000 tracked files or more, or a slow status | git config --local core.untrackedCache true and git config --local status.showUntrackedFiles all | Yes |
| Write the commit-graph | 2,000 commits or more, without a commit-graph or with many commits outside it | git maintenance run --task=commit-graph --no-quiet | Yes |
| Pack loose objects | 1,000 loose objects or more, or 64 MB or more in loose objects | git maintenance run --task=loose-objects --no-quiet and git prune-packed | Yes |
| Consolidate packs (multi-pack index) | 10 packs or more | git repack --geometric=2 -d --write-midx (Git 2.34 or newer; before that, the incremental-repack task and git multi-pack-index expire) | Yes |
| Pack refs | 1,000 loose refs or more | git pack-refs --all | Yes |
| Full cleanup (gc) | 6,700 loose objects or more, or 50 packs or more (the limits of Git's automatic gc) | git maintenance run --task=gc --no-quiet | No ("caution" label) |
When it turns on fsmonitor or the untracked cache, the app also runs a git status that writes the
index, so the cache takes effect right away.
Caution
Full cleanup (gc) can take several minutes and use every processor.
Like a regular git gc, it removes unreachable objects older than 2 weeks (discarded commits that
aren't on any branch, tag, stash or in the reflog) and expires old reflog entries. That's why it's
never checked by default.
The Confirm optimization window lists the commands in the order they'll run: "These commands run in this repository, one at a time, in the order below. Settings go only to this repository's .git/config; nothing is scheduled in Windows." It adds the warnings that apply:
- "gc can take several minutes and use every processor, and it removes unreachable objects older than 2 weeks."
- "fsmonitor keeps a Git process (git fsmonitor--daemon) running in the background for this repository."
- "With status.showUntrackedFiles=all, git status in the terminal also lists each file inside new folders."
- "You can cancel midway: the current command is stopped and the next ones don't run."
Click Apply (or Back). While it runs, "Git's progress also shows in the toolbar indicator." If the tab is busy with another operation, the screen waits ("Waiting for the tab to be free…").
The Optimization result screen shows each command with "Done", "Failed", "Canceled" or "Not
run", the summary ("N commands completed." or "N commands failed; the others ran.") and the
Before and after table. The git status time varies with the Windows disk cache: compare more
than one measurement. See recommendations goes back to the list; Close exits.
If you canceled, "Locks and temporary files left by the canceled command were removed: ‹files›" says what the app cleaned up.
Repository settings block, the Turn off… button next to the setting that's on.
# fsmonitor
git config --local core.fsmonitor false
git fsmonitor--daemon stop
# untracked cache
git config --local core.untrackedCache false
git config --local --unset status.showUntrackedFiles
git update-index --no-untracked-cache
The confirmation warns: "This repository's fsmonitor process is stopped." The confirm button is Turn off.
Shows the 20 largest files in the whole history, including old versions that have already left HEAD. It helps you find out what makes the repository heavy.
- In the Largest files in history part, click Search.
- The search shows "Searching (up to 60 s)…", then "Measuring objects: N" and "Finding paths in history: x of y". Click Cancel to stop.
- The table has File, Size, In pack ("Space used in the pack (compressed or as a delta)") and Where: "in HEAD", "history only", "no path: not on any branch, tag or stash" or "path not found in time".
- Use Search again after a change.
- "The search stopped at the 60 s limit: the list may be incomplete and some paths may be missing."
- "Search canceled: the list may be incomplete."
- "Wait for the largest-files search to finish (or cancel it).": the apply button waits for the search.
- "Another operation is running in this repository; search again in a moment."
When HEAD has large or binary files (binaries of 512 KB or more, by extension, or any file of 5 MB or more), the Large files: Git LFS part lists the types, with Pattern, Files, Total and Largest, and explains that every version of them stays whole in the history.
Below come the Suggested commands (the app doesn't run them):
git lfs track "*.psd" "*.mp4"
git lfs migrate import --everything --include="*.psd,*.mp4"
Caution
"git lfs migrate rewrites history (every commit gets a new SHA): agree on it with your team first, and you'll need to force push every branch afterwards."
The Open Git LFS button takes you to the Git LFS screen, where you track the patterns without rewriting the history. Without Git LFS installed, the part warns "Git LFS isn't installed."
"The app doesn't run these suggestions: they change how you work with the repository."
- Sparse checkout: with 30,000 tracked files or more, and sparse checkout still off, it suggests keeping only the folders you use in the working directory. Open sparse checkout button. See Sparse checkout.
- Partial clone: in a repository that isn't partial yet, with 100,000 commits or more, or 1 GB or more in packs, it suggests cloning again as a partial clone, into a new folder. Clone with options… button. See Shallow clone and partial clone.
Optimization isn't part of Ctrl+Z. The packing tasks and the commit-graph don't change the repository's content: only the way it's stored. The status caches are turned off with Turn off…. What the full cleanup (gc) removed doesn't come back.
- "Go back to this repository's tab to continue.": the screen belongs to the repository of another tab.
- "Another operation is running in this repository; try again in a moment."
- "The optimization didn't finish."
- "You can't turn the same cache on and off at once."
There's no setting of its own in Preferences. fsmonitor requires Git 2.37 or newer: see Git version.
- Git LFS and locks
- Sparse checkout
- Official documentation: git maintenance (opens another site) and git gc (opens another site)