blog: Getting rid of cgit

I replaced cgit on my git server with a more minimal web representation. I think that people are, if at all, either interested in the current content of master/HEAD or want to clone the repo anyway.

Dumping master/HEAD


set -eu


files=`git ls-tree --full-tree -r --name-only HEAD`

rm -rf "$DIR"

echo "$files" | while IFS=$'\n' read -r f; do
  subdir=`dirname $f`
  mkdir -p "$fulldir"
  git show HEAD:"$f" > "$fullpath"
  if file "$fullpath" | grep -q "text"; then
    echo "Binary file" > "$fullpath"

This script is called from post-receive hooks with the repo name as argument.

Public clone

The git-daemon allows public cloning via the git protocol on port 9418. Repositories need an empty git-daemon-export-ok file. I also set –base-path to the git repo root folder, so that stuff viewed in e.g. can be cloned with git clone git://

Nginx file type

The git dump has its own nginx server configuration. Inside I made sure to only serve files as text/plain:

server {
  types { }
  default_type text/plain;
  listen 80;
  autoindex on;
Posted in programming tech fatigue
2021-02-24 20:06 UTC