Skip to content

Instantly share code, notes, and snippets.

@w0ng
Forked from thomcc/faster-git.md
Last active July 10, 2021 01:19
Show Gist options
  • Save w0ng/3695e5366c2bc23c2077788398d309cb to your computer and use it in GitHub Desktop.
Save w0ng/3695e5366c2bc23c2077788398d309cb to your computer and use it in GitHub Desktop.

Steps to faster git on mac.

  1. Update to git 2.16

  2. Setup file monitoring with hgwatchman

    1. Run
    $ brew install watchman
    $ cd /path/to/mozilla-central
    $ watchman watch-project .
    

    2. Download my slightly modified version of the default git fsmonitor-watchman hook from here and put it at .git/hooks/fsmonitor-watchman. 3. Run git config --local core.fsmonitor ".git/hooks/fsmonitor-watchman" 2. Install https://github.com/jgavris/rs-git-fsmonitor 3. Run git config --local core.fsmonitor rs-git-fsmonitor

  3. Enable git's split-index feature

    1. Run
    $ git update-index --split-index
    $ git config --local core.splitIndex true
    
    1. Optionally, run git config --local splitIndex.maxPercentChange 10. The default is 20, which is too high for repos the size of gecko. YMMV for a good value, you can also skip this and run git update-index --split-index whenever things start getting slow to force it to re-split the index.
  4. Enable git's untracked file cache

    1. Run git update-index --test-untracked-cache. If it tells you you can, then
    2. Run git update-index --untracked-cache, and git config --local core.untrackedCache true.
  5. If you still have a slow prompt, it's probably computing modifications in a bad way. Parsing them out of git status --porcelain is the fastest, but many use git diff --name-only or similar, which is very slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment