The devmanual has some good introductory material on gentoo.git settings and best practices but this page aims to document some neat bonus features and config options available in git.
Tell git to optimize for many small files (https://github.blog/2019-11-03-highlights-from-git-2-24/).
This enables the 'many files' macro which can change meaning depending on the version of git: it's a metasetting. So, if there are future improvements/improved advice on what's best for repositories with many files, you'll automatically pick it up without modifying individual "real" settings.
Run this within a git repository (need to run this, like all the commands here, once per repository):
git config feature.manyFiles true
dev-util/watchman is a tool by Facebook much like app-admin/entr. git ships with hooks that integrate with watchman to speed up commands like git status!
To enable it, first install it:
emerge --ask dev-util/watchman
Then run the following within a git repository:
cp .git/hooks/fsmonitor-watchman.sample .git/hooks/query-watchman
chmod +x .git/hooks/query-watchman
git config core.fsmonitor .git/hooks/query-watchman
git since v2.31 supports the git maintenance subcommand. No longer must users run several commands to keep their repositories in good health.
It has support for cron and since 2.34, it can make use of systemd user services, so there's no excuse not to use it.
git maintenance start # sets the needed config options *and* schedules it to run automatically
git maintenance run # run it manually as a one-off to get the benefits immediately
Note that it doesn't, as of 2.38.1, add git gc to any scheduled runs. To run it weekly:
git config --global maintenance.gc.schedule weekly
For systemd, it may be needed to explicitly run:
git maintenance start --scheduler=systemd-timer
There are a few additional options that can be set which might help. You should research them first though.
This is off by default (for now?) because it doesn't help on rotational media or other slow disks. It is however worth it on SSDs and such.
Read more in the github's git v2.33 roundup or another writeup.
Run the following:
git config --global checkout.workers 0
Where the '0' denotes that the number of cores should be used.
This isn't yet enabled by default. See again github's git v2.31 roundup.
git config pack.writeReverseIndex true
git repack -Ad