commit adc9770d8a945ebd8091cd1a84c465f6c9d6d2eb
parent 693b60e7a1bc336d54079b1eea2e0bd25ad18808
Author: Riaz <riaz@riazj.com>
Date: Fri, 8 Aug 2025 14:42:36 -0700
Write article about self-hosting git repos
Diffstat:
2 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/articles/git.html b/articles/git.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>Self-Host Git Repositories with Stagit | Riaz's Website</title>
+<link rel="stylesheet" href="/style.css">
+<link rel="icon" href="data:,">
+<meta name="description" content="How to self-host git repositories with stagit on NearlyFreeSpeech">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body>
+<h1>Self-Host Git Repositories with Stagit</h1>
+<hr>
+<article>
+<p>By following <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server">these steps</a>, I moved my repositories from Codeberg to this website. I skipped a few parts since I authorized my ssh key under NearlyFreeSpeech's member profile page, and I don't have root access to create a git user.</p>
+<p>Different directories can be made to separate the bare repos' files from the ones generated by stagit, but I prefer keeping them together. If you decide on using one folder, make sure that there are not any rules in .htaccess that automatically remove the .html extension so that refs.html is not redirected to the refs/ folder.</p>
+<pre>
+cd /home/public
+mkdir git
+cd $_
+git init --bare test
+</pre>
+<p>On your machine, you can now <code>git clone user@host:git/test</code> or <code>git remote add origin user@host:git/test</code> in an already existing repo. To clone it read-only over HTTPS, <code>mv hooks/post-update.sample hooks/post-update</code>. It can run now instead of waiting to push with <code>sh hooks/post-update</code>.</p>
+<p>I tried <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Git-Daemon">allowing access over the git protocol</a>, but I got the error message below. Information on protocols are available <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols">here</a>.</p>
+<pre>
+$ git clone git://riazj.com/git/riazj.com
+Cloning into 'riazj.com'...
+fatal: unable to connect to riazj.com:
+riazj.com[0: 2607:ff18:80:4::6db8]: errno=No route to host
+riazj.com[1: 208.94.117.16]: errno=Network is unreachable
+</pre>
+<p>Back on the host, install stagit.</p>
+<pre>
+cd /home/private
+git clone git://git.codemadness.org/stagit
+cd stagit
+make
+make install
+</pre>
+<p>I set PREFIX to ~/stagit in the makefile and ran the command below to include the executables in my PATH.</p>
+<pre>echo 'export PATH="/home/private/stagit/bin:$PATH"' >> ~/.zshrc</pre>
+<p>Copy your logo and favicon if needed and <code>stagit/style.css</code> to your git folder. Inside a repo, run the following commands to set the owner, description, and URL for cloning.</p>
+<pre>
+echo "Riaz" > owner
+echo "test repo" > description
+echo "https://riazj.com/git/test" > url
+</pre>
+<p>Modify <code>stagit/example_post-receive.sh</code> for your use case and place it at <code>hooks/post-receive</code> for each git repo. Consider symlinking it. I use <a href="/git/riazj.com/hooks/post-receive">this post-receive hook</a> to generate the stagit pages in the same folders as the bare repos.</p>
+<p>If you ran stagit on a repo and later change the description, running stagit again will not show this change on all files unless the commit folder was removed first. Alternatively, you can manually edit the HTML.</p>
+</article>
+<footer>
+<hr>
+<a href="/">Home Page</a></footer>
+</body>
+</html>
diff --git a/index.html b/index.html
@@ -15,6 +15,7 @@
<nav><a href="git/">Code</a> | <a href="contact">Contact</a> | <a href="links">Links</a></nav>
<h2>Articles</h2>
<ul>
+<li><time datetime="2025-08-08">2025 Aug 08</time> <a href="/articles/git">Self-Host Git Repositories with Stagit</a></li>
<li><time datetime="2025-07-28">2025 Jul 28</time> <a href="/articles/wmutils">Managing Windows Without a WM</a></li>
<li><time datetime="2025-07-24">2025 Jul 24</time> <a href="/articles/pw">Write a Password Manager in POSIX Shell</a></li>
<li><time datetime="2025-07-19">2025 Jul 19</time> <a href="/articles/tldr">Simple TLDR Client Written in POSIX Shell</a></li>