It seems Git 2.46.0 brings a new feature to fix exactly this problem.
Excerpt from the [release notes][1]:
> The safe.directory configuration knob has been updated to optionally allow leading path matches.
Excerpt from the [git config reference documentation][2]:
> Giving a directory with /* appended to it will allow access to all repositories under the named directory.
[1]: https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.46.0.txt
[2]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-safedirectory
It seems Git 2.46.0 brings a new feature to fix exactly this problem.
Excerpt from the [release notes][1]:
> The safe.directory configuration knob has been updated to optionally allow leading path matches.
Excerpt from the [git config reference documentation][2]:
> Giving a directory with /* appended to it will allow access to all repositories under the named directory.
[1]: https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.46.0.txt
[2]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-safedirectory