GitHub has become synonymous with Git-based software development, to the point that some people don’t realize that GitHub is merely a product owned by Microsoft, while Git itself is a free and open source distributed version control system.
Just because GitHub exists doesn’t mean you need it. GitLab, Codeberg, or Forgejo are other options if you need to collaborate with others. But if you are like me and just enjoy coding little projects for yourself without sharing them anybody, then self-hosting Git repositories is a viable alternative, or at least a backup solution.
And it is dead simple. All you need is SSH access to a machine with Git installed. Any box with a home directory will do. Can be at your home or a rented VPS.
I run a VPS at git.raupach.io and connect through SSH.
Here is my .ssh/config
Host git.raupach.io
User ec2-user
HostName git.raupach.io
AddKeysToAgent yes
IdentityFile ~/.ssh/FreeBSD.pem
To set up a new remote repository on git.raupach.io, which I will then clone on my development machine (aka laptop), I connect with SSH and use Git to initialize a new empty repository.
Connect with SSH:
ssh git.raupach.io
Initialize a new bare Git repository:
git init --bare petproject.git
That is all there is to it. Now I have a remote repository.
The repository is only a folder. The .git extension is cosmetic and not required.
To checkout the remote repository on my laptop I run:
git clone git.raupach.io:petproject.git
I can now push and pull just like on GitHub and be a
happy little coder.