Minimal git server and web interface setup
There are basically 3 methods to serve git repositories described in progit: http, git and ssh. I happen to find using http to serve another protocol retarded no matter the justification so I will use git and ssh. I'll also be using OpenBSD for the server OS as I find it the most sane option.
Setting up a git daemon to serve your repository is exceedingly easy. On OpenBSD you just need to install git
doas pkg_add git
and append the following line to
gitdaemon_flags="--export-all --reuseaddr --base-path=/var/www/git/ /var/www/git/"
You can read what all the options do in the man page.
Then start and enable the daemon.
doas rcctl start gitdaemon doas rcctl enable gitdaemon
To create a repository to serve with the git daemon, initialize a bare repository in the directory specified above.
cd /var/www/git git init --bare repo-name.git
Then push your repository to it with ssh.
git push server:/var/www/git/repo-name.git
The push command is from the root user of the server you have access to.
It's shorthand for scp and comes from a record in
Host server HostName 188.8.131.52 User root port 22
Make sure the git daemon has permision to read the bare repository. Then you can now fetch it like so:
git pull git://domain.tld/repo-name.git
You can change the origin of that repository to the above.
git remote set-url origin git://domain.tld/repo-name.git
If you want more granular access control (for your supposed maintainers), you can create a git user and follow the steps in progit. For most small projects, I find the above setup good enough.
I'll be using stagit for the web interface. My first choice was actually cgit but it's a huge pain to setup because it assumes bloat. There are a few things I don't like about stagit, the most important of which is that you can't copy code from the webview without also including the line numbers. Screw it though, that's why it's called a webview. I'll take its simplicity over the bloated alternatives every time.
The first thing we'll need to do is to inatall stagit.
doas pkg_add stagit
The easiest way to create the static files is to use a script provided
in the upstream repository. It might be hiding somewhere in the
documentation but I couldn't find it. Before you run it you should edit
description files in the bare repositories.
To get the script, clone the repository
git clone git://git.codemadness.org/stagit
and change the
reposdir variable in
example_create.sh then run the
script in the directory you want the static files to end up. You can use
the css, logo and favicon that comes in the repository but I like
my css better. You should use it
That's it. You now have a fully functional self-hosted git server. You can use email to process pull requests, just as Linus intended. If you want to look at what the finished product looks like, you can visit my instance.