Recently on The Orange Site and elsewhere I have seen various discussions regarding self-hosting a git "forge" such as Gitea, Gogs, or Gitlab, or some other alternative that integrates with ActivityPub or atproto etc.
These "forges" provide, in addition to git repo hosting, various social features and features for issue tracking and managing pull requests, as well as web interfaces, and are variously difficult to install and maintain.
I noticed that some folks online, who were introduced to git through GitHub (I think), don't realize that git affords for usage in a distributed manner without specialized software.
If you don't need a web interface, all you need is git and ssh.
Let's say you have a VPS, we'll call it my-cool-vps.silly.business
. And let's say you have some local repository that you've been developing. You want to place your code on the VPS so that you can build a version there, and to share it with someone interested in your project.
Log in to the remote and create an empty repo
~/my-project $ ssh [email protected] me@my-cool-vps $ mkdir my-project me@my-cool-vps $ git init --bare . me@my-cool-vps $ exit
Add a new remote
~/my-project $ git remote add vps [email protected]:~/my-project
and push to it
~/my-project $ git push vps current-branch
…and that's it. Now you can use that remote just like the one you're used to on GitHub or wherever. The only caveat is that if you're working on your VPS and you check out a branch there, you can't push to it from another machine while it is checked out.
If you want to grant limited access to the code, you could create the project in a directory owned by a dedicated user, and use SSH keys to manage access. This is how the forges work, and it is why they need you to create a git
user as part of installation. You can copy this pattern without installing the forge if you need this functionality.
Or install one of the forges, that's fine too. The point of this post is not that those are bad or wrong. The point is that you might not need them, and if not, you might be able to move your code around without installing anything extra at all. Because you already have sshd
running, don't you?