Most of the online Git services have become free, and some of them do offer free private repositories, good choices to go with if we want to open source something.
But sometimes when we're starting new projects, or when we have some confidential projects we want to put in some private spaces and we do not trust public service providers, We need our own Git server(s).
There are also some awesome open sourced self hosting solutions, like Gitea. But even though claiming to be painless, which some of them kinda are, they are still way too overkill for simple repositry service. Especially when there is only one user on the sight.
Good thing is, Git does come with built in support for SSH protocol, that makes creating simple repositories easy.
We just need to invoke one command, on the server:
git init --bare ~/PROJECT_NAME
Then the new repository is setup and good to go, we can use it just as we are on Github or something alike.
For example, on the client, start with cloning the repository:
git clone USER@SERVER:PROJECT_NAME
or for existing directory:
cd PROJECT_DIRECTORY
git init
git remote add origin USER@SERVER:PROJECT_NAME
Because of the fact that it is based on SSH, we will just do access control with SSH, setting up passwords, authorizing public keys, blocking or whitelisting IP addresses, anything.
That's it! Have fun with your new journey!