top | item 31432936

Poll: Self Hosting Git Repositories

64 points| gmemstr | 3 years ago | reply

I'm looking to setup a git host to at the very least mirror my git repositories, but more likely to migrate to full time. Suggestions are welcome, but I'm also curious what HN uses!

82 comments

order
[+] rapnie|3 years ago|reply
Gitea (originally a fork of Gogs) is moving fast, and they are adding ActivityPub federation support to the software. This will allow you to collaborate with projects hosted on remote Gitea instances (and other software once they add federation support too). If you are working on FOSS then Codeberg [1] is a good Gitea instance, which offer Woodpecker CI and Codeberg Pages.

[1] https://codeberg.org

[+] DoctorDabadedoo|3 years ago|reply
Gitea is love. There are not a lot of shenanigans and it just does the job. If you want vcs with an online interface it's great for personal use and smaller teams.

If you want fancier stuff like integrated CI/CD that is more common out there, Gitlab is an option, but running it by yourself it's not as simple (as gitea), for example.

[+] jarbus|3 years ago|reply
Was just about to say this, I’m so excited for Gitea to get federation support and think they could really give GitHub a run for their money. I think a lot of major foss projects would switch over to a self hosted instance if it didn’t require users to create an additional account for every instance
[+] dividedbyzero|3 years ago|reply
I believe the Gitea people are also about to add an artifact registry feature.

I run a Gitea instance on my Synology to act as a source for flux2 on the living room Kubernetes cluster. I don't want to have that on Github so it'll all work without internet connectivity (still a WIP though). I had my own Gitlab for a long time but at some point its hunger for resources made it uneconomic for my use case. Gitea does less but in a fraction of the resources.

[+] synergy20|3 years ago|reply
same here, gitea for a few years, works great for all my personal git repos. it's essentially my own github/gitlab that runs off one binary.
[+] iveqy|3 years ago|reply
if it's for personal use and no access rights are needed, just use ssh.

If you need to add more people, but don't require access right for the git repos (i.e. everyone will be able to force push). Still use ssh, but create a git user and git-shell as the shell to improve security.

If you want to go one step up, I was looking at soft-serve, however it's too immature yet. So I added a git-shell-commands folder and added list command that will list my git repos.

It's really simple!

If you need access rights and reviews, things will be a bit more complicated. Although git-shell seems pretty easy to add some access rules to, if not gitolite is better. For browsing, cgit and gitweb should be obvious choices, however I don't really see the point for a minor site.

For code review, I'm really voting for git-appraise to take off. Once I get a coworker, that's what we will be using.

[+] capableweb|3 years ago|reply
> if it's for personal use and no access right are needed, just use ssh.

This! I think many people don't realize how easy it is to host git repositories over just pure ssh. I backup all my git repositories this way, and also have a usb disk drive with backups (which is super easy to setup, just add a git remote with a unix path to where you wanna send it). Each repository I have have three remotes (`origin` which is usually GitHub/Codeberg, `ssh` which is my remote backup and `usb` which is my disk drive). My alias `gp` pushes the current branch to all three simultaneously.

[+] jason_slack|3 years ago|reply
> reviews

Are you saying that I can self-host and have the same "review" functionality as GitHub when reviewing PR's?

[+] teekert|3 years ago|reply
Do you mean use VSCode with Remote-SSH and just work on a server?
[+] eixiepia|3 years ago|reply
Anything else than GitLab, it's so slow and bloated. With every "update" it seems to get even slower and depend even more on javascript. I really hate how so many open source projects shifted to this abnormation because Microsoft acquired GitHub, I mean, regardless of what evil shit Microsoft could think up, it can't be worse than having to deal with this javascript turd. If your web interface can't even just display simple information like issues page or merge requests, without depending on a huge pile of steaming javascript, you have FAILED in web design. I cry every time I'm forced to use GitLab. Just my two cents.
[+] i0nutzb|3 years ago|reply
You may want to give more details about your usecase: do you need _only_ git hosting or other features too (e.g. issue tracker, CI/CD pipelines)? How many users will use this setup? Do you have a dedicated machine or you run it locally (e.g. in a docker container?? Hosting locally or in cloud?

IIRC Gitolite was aquired by Gitlab a while back, Gitweb is not really a git hosting, it's more like a web view of your `git log`

Gitlab needs at least a couple of gigs of RAM to run well, double/triple that if you need CI/CD.

I have no experience wiht gogs/gitea.

[+] fanf2|3 years ago|reply
Gitolite is open source maintained by Sitaram Chamarty https://gitolite.com/ so I don't think it's even possible to acquire it in the way you suggest.

Gitweb can work quite nicely with gitolite to provide a web view of your repositories, with access control managed by gitolite.

[+] gmemstr|3 years ago|reply
This poll is really me being curious about what the citizens of HN use themselves. My own use case would benefit greatly from CI/CD pipelines, but beyond that I'm mostly looking for a nice web interface to expose the repository contents.
[+] bananaramallama|3 years ago|reply
If you don't need a front-end, push and pull directly from git. https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-...
[+] shadowofneptune|3 years ago|reply
I am surprised that this got downvoted so quickly without comment. I'd genuinely like to know what the downsides of doing it this way would be. Having to manage your own SSH keys seems like a problem, but I don't know what the others would be since my needs aren't very big.
[+] 8fingerlouie|3 years ago|reply
Gitea all the way.

Lightweight (can run on a RPi unlike GitLab), does everything you expect, can work with SQLite or MySQL/MariaDB or PostgreSQL, and can sync remote (GitHub/Bitbucket/whatever) repositories locally.

[+] gspr|3 years ago|reply
I voted "other": I just put bare git repositories on my VPS, and interact with them over SSH. Tiny and simple cgit exposes a read-only HTTPS interface for the repos that I want to share publicly.
[+] conaclos|3 years ago|reply
Similar here. So simple:

  user@remote ~ > git init --bare myproject.git
  user@local myproject > git remote add vps user@remote:myproject.git
[+] arichard123|3 years ago|reply
I use ssh, and a script that manages ssh keys and system user accounts, with a umask change and some symlinks. This means I can add read-only ssh access for deployment keys. The remote address would be of the form ssh://{clientname}[-ro]@domain:port/~/repos/{reponame}.git

The [-ro] gives the readonly access. I use git-shell to prevent normal ssh access to the server on those accounts.

[+] floor_|3 years ago|reply
I also use this method. Getting some front-end UIs to work with ssh is kind of a pain though.

That said, I think what the OP actually wants it a web front-end.

[+] lf-non|3 years ago|reply
You may also want to include onedev [1][2] in your exploration (https://code.onedev.io/) if you also need good CI/CD integration.

My experience (as a user) has been pretty good, though I was not involved in the adminstration/setup related aspects but I have been told it doesn't require a lot of maintenance effort.

[1] https://github.com/theonedev/onedev [2] https://code.onedev.io/

[+] jamesu|3 years ago|reply
Can't believe this is not better known. I had huge problems with a git-lfs setup being slow on gitea, but I tried out onedev and its implementation was a magnitude faster. Plus configuring and launching the thing was pretty simple.... easy win!
[+] brynb|3 years ago|reply
I made Redwood, a general purpose p2p/distributed database (and blob store) with pluggable merge algorithms (including some cool CRDTs, like what @josephg is working on).

Turns out it makes for a great self-hosted git solution, so I made a git remote plugin that allows you to interact with it using regular vanilla git commands: https://github.com/redwood/redwood/tree/libp2p-connectivity2...

[+] hamdouni|3 years ago|reply
Gitea+drone [0] for all my projects for several years : dockerized for even more simplicity. An update is nearly just 'compose pull && compose up'.

[0] https://www.drone.io/

[+] harryvederci|3 years ago|reply
I know this specifically asks for git, but I just want to mention fossil[0] here as it has git export, a built-in wiki + ticket system, etc, and is incredibly easy to self-host.

[0] https://fossil-scm.org/ (created by Richard Hipp, the guy that made SQLite)

[+] stevekemp|3 years ago|reply
I used to use a self-hosted instance of gitbucket:

https://github.com/gitbucket/gitbucket

That's a single .WAR file, running under Java which was nice and easy to get started with, and even has support for some trivial CI/CD actions. Unfortunately a sudden death of the docker container it was running with corrupted the internal database to the extent that it wouldn't restart. (All my repositories were fine, on-disk, but the issues and similar stuff was mangled beyond belief.)

At that point I realized that I didn't use the issues, or pull-request facilities except very very rarely, so I switched to using bare repositories on a remotely hosted virtual-server.

[+] angst_ridden|3 years ago|reply
I just host on my VPS and use ssh to access. My VPS gets imaged nightly (for one kind of backup) and versioned back ups using Restic.

I only collaborate with folks who I trust enough to give accounts, which means most are just personal repos.

[+] rollcat|3 years ago|reply
SourceHut (https://sr.ht) is open source, although I've never tried setting it up for self-hosting. Anyone here with experience?
[+] schube|3 years ago|reply
On Alpine Linux it’s quite simple. Each service of sourcehut is already packaged for Alpine (SourceHut’s author Drew Devault is also an Alpine contributor.) so all that’s needed is a few `apk add` and basic configuration. And a PostgreSQL database. I never finished setting up the CI service though because it requires building your own VM images to run scripts in and that was more work than I was willing to do at the time. But since it’s all modular you can have a working instance without the CI service.
[+] stillbourne|3 years ago|reply
I run gitlab on my kube cluster and installed that via helm charts and configured the omniauth system to communicate with my keycloak server via oidc. Overall complexity 6/10 took about 5 hours to fuss with it the first time. Subsequent deployments became easier. I hear Gitea is also a good selfhosted solution and less complex to install. However, I went with Gitlab specifically because we use it at work and I want to practice gitops/devops with it.

https://docs.gitlab.com/charts/installation/

[+] lifepillar|3 years ago|reply
I wonder whether people monitor resources consumed by processes… A couple of years ago I had installed Gitea, but it was constantly using between 5-10% CPU. I switched to Gogs, and it doesn’t waste CPU cycles. So, I have stayed with Gogs. My needs are minimal (self-hosting for personal use), so I could probably switch to something even more minimal, but so far Gogs works fine.
[+] gonewest|3 years ago|reply
We're serving git over https using apache2, where apache handles authentication via LDAP. We also serve subversion repos with a similar setup. We use separate web services for search, code review, CI, and issue tracking.

Running this way does involve more moving parts, but every part is relatively self-contained and we can replace one thing without disrupting everything.

[Edit] one other benefit I should add, all the other services like code review and CI are compatible with git and svn, so the development teams have consistent tools regardless which vcs they're running for a particular project.