Skip to content
Versora

Manual

Repository

Optimize repository

7 min read

On this page

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.

Opening the diagnostics

Where to find it

  • 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").

Step by step

  1. 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.").
  2. Read the numbers, the settings and the recommendations (described below).
  3. Check the recommendations you want to apply and click Apply N recommendations….
  4. Review the commands in the Confirm optimization window and click Apply.
  5. Follow "Command N of M". To stop, click Cancel.
  6. See the Optimization result, with Before and after.

The footer shows "Diagnosed in ‹time› · Git ‹version›" and the Diagnose again button.

The repository's numbers

BlockRows
ObjectsObjects, In packs, Packs (count and size), Loose objects, "Loose, already packed", Stray files
RefsLocal branches, Remote branches, Tags, Other, Loose refs (or "reftable format")
HistoryCommits, commit-graph (how many commits it covers, "not written" or "(N missing)"), Multi-pack index ("yes" or "no")
FilesTracked, Untracked

At the end, Output of git count-objects -vH shows Git's text, as Git wrote it.

The repository settings

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"):

KeyWhat it shows
core.fsmonitoron, 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.untrackedCacheon, off or not set
feature.manyFilesthe 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.commitGraphon, off or not set
core.multiPackIndexon, off or not set

With fsmonitor or the untracked cache on, the Turn off… button appears, which goes through the same confirmation.

The recommendations

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.

RecommendationWhen it appearsCommandsChecked 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 setgit config --local core.fsmonitor trueYes
Turn on the untracked files cache (core.untrackedCache)5,000 tracked files or more, or a slow statusgit config --local core.untrackedCache true and git config --local status.showUntrackedFiles allYes
Write the commit-graph2,000 commits or more, without a commit-graph or with many commits outside itgit maintenance run --task=commit-graph --no-quietYes
Pack loose objects1,000 loose objects or more, or 64 MB or more in loose objectsgit maintenance run --task=loose-objects --no-quiet and git prune-packedYes
Consolidate packs (multi-pack index)10 packs or moregit 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 refs1,000 loose refs or moregit pack-refs --allYes
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-quietNo ("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.

Confirming and applying

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 result

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.

Turning off fsmonitor or the untracked cache

Where to find it

Repository settings block, the Turn off… button next to the setting that's on.

What Versora does in git

bash
# 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.

Largest files in history

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.

Step by step

  1. In the Largest files in history part, click Search.
  2. The search shows "Searching (up to 60 s)…", then "Measuring objects: N" and "Finding paths in history: x of y". Click Cancel to stop.
  3. 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".
  4. Use Search again after a change.

Caveats and messages

  • "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."

Large files: Git LFS

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):

bash
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."

Other suggestions

"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.

How to undo

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.

Caveats and messages

  • "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.

See also