{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigb5epuc2ycvdqtoim2htp22hvp7cxxf6xgrw33xuqeaf5zr57b6a",
"uri": "at://did:plc:g6ylepvyexpkh7neqdzsj27a/app.bsky.feed.post/3mkjndwnac2a2"
},
"path": "/blog/kiss-git/",
"publishedAt": "2026-04-20T00:00:00.000Z",
"site": "https://angelwood.xyz",
"tags": [
"uptime",
"issues",
"stagit",
"stagit-post-receive from the official repo",
"GIT HTTP Dumb Protocol",
"cgit",
"ليلى النحلة",
"blogpost",
"Caddy documentation",
"@git"
],
"textContent": "Most of my projects are hosted on either sr.ht and/or codeberg. But due to some uptime issues on both providors, I have been searching for a self-hosted solution in the case that one or both of them are down.\n\nAfter some searching I found stagit, a small fully static git hosting platform with minimal dependicies. Combined with a simple http proxy a fully stattic git hosting system is possible!\n\n## Getting started!\n\nAfter installing stagit you should have both `stagit` and `stagit-index` in your path. You will also need to get stagit-post-receive from the official repo and install it into the path. Easiest way of doing that is putting it in `/usr/local/bin/`\n\nOpen the post-receive script in any text editor and change the variables at the top, Mainly `reposdir` and `htmldir` to match where you have decided to store your html and git repos on your system.\n\nHere is an example:\n\n\n # ... Start of the file ...\n\n # config\n # paths must be absolute.\n reposdir=\"/var/git/\"\n dir=\"${reposdir}/${name}\"\n htmldir=\"/var/www/git.angelwood.xyz\"\n stagitdir=\"/\"\n destdir=\"${htmldir}${stagitdir}\"\n cachefile=\".htmlcache\"\n # /config\n\n # ... Rest of the file ...\n\n\nNow that we have stagit setup, lets create a repo! To make our lives easier we can create a small script called `stagit-init-repo` that sets up the required hooks and symbolic links\n\n\n #!/usr/bin/env sh\n git init --bare $1\n cd $1\n echo https://git.angelwood.xyz/$1 >> url # generate URL automatically\n ln -s /usr/local/bin/stagit-post-receive.sh hooks/post-receive # auto-updates stagit on each push\n mv hooks/post-update.sample hooks/post-update # allows static git pull by adding git update-server-info\n chmod ug+x hooks/ # sanity check on permissions for the hooks\n\n #usage: stagit-init-repo repo-name\n\n\nThe last step is to point your HTTP(s) server of choice at whereever you set `htmldir` to be. If this server is not ment for the general public you can stop here, but you can continue on if you want anyone to beable to git clone it!\n\n## Git Cloning without a CGI\n\n99% of git servers use a CGI to allow http transfers, but we can use the GIT HTTP Dumb Protocol to keep our server 100% static!\n\nIn your HTTP server's configuration you need to create a small redirection rule to change what directory to point to based on the useragent. When a browser access a repo it should direct itself to the `htmldir`, but when a git useragent is used it should be redirected to `reposdir`. Here is an example for Caddy:\n\n\n git.angelwood.xyz {\n root /var/www/git.angelwood.xyz/\n file_server\n\n @git {\n header User-Agent git/*\n }\n\n handle @git {\n root * /var/git/\n file_server\n }\n }\n\n\nTo ensure that this works you **need** to have the `post-update` script run the command `git update-server-info` to create some additional helper files for the Dumb HTTP protocol. You can do this after the fact if you have already created repos without this hook already established. My example `stagit-init-repo` script already sets this up for you so you should all ready to go!\n\n## Drawbacks\n\nThis system does have some drawbacks, having a static git repo means that every page needs to be pre-calculated. The Dumb HTTP protocol also has the drawback of being slightly more inefficient has git has to precalculate your request before hand. If you still want a lightweight git hosting solution that is usable on large repositories I can higly recommend cgit.\n\n## Special Thanks\n\n * Thank you to ليلى النحلة for innitially showing me `stagit`\n * This blogpost by a3nm for some helpful tips\n * The wonderful Caddy documentation\n\n",
"title": "My Keep-It-Simple-Stupid Git Setup",
"updatedAt": "2026-04-20T00:00:00.000Z"
}