I am writing this on the first Saturday of September 2022 but the solution described is in use since exactly two years ago already.
I have a repository, hosted on GitHub, it's public and it's mkf/homedirconfig.
They way I set it up:
alias gd env GIT_WORK_TREE="$HOME" \ GIT_DIR="$HOME/.gd" \ GIT_CONFIG="$HOME/.gdconfig" \ git -c "core.excludesfile=$HOME/.gdignore"
I also used to achieve identity between branches and then have the branches have some common root, but not doing that anymore.
the .git directory is instead named .gd
the repository's .gitconfig is instead stored as .gdconfig
instead of .gitignore i have .gdignore (funny TIL Godot the game engine has its ignore file named the same haha)
I used to instead try staging the file .gd/info/exclude (counterpartly, .git/info/exclude)
https://github.com/mkf/homedirconfig/commit/7a6f15ebeeda04a3258dc70ab2f5e2e9d72f2854
That wasn't too neat to manage.
It's benefit: it could both be managed by git in a non-aliased repo, as well as being immediately present there and not needing a core.excludesfile setting.
https://wiki1.mikf.pl/git/excludefiles.html
Whoosh, I just reminded myself of my old blog, and there is a mention of this repo from January 2020. So that's over 2.5y ago.
"Today I asked on Super User: Are .gitignore files from directories above the repository's or from home directory loaded in any versions of Git?" (250 words)
https://log1.mikf.pl/today_i_asked_superuser_gitignore/
I guess I just didn't host it on Github back then, but on a regular ssh *nix.
reading @aelspire's