How do git remotes work? And how do I self-host my own?

What it takes to create the simplest, barest self-hosted git remote, and learn stuff about git in the process.