riazj.com

source code for this website
git clone https://riazj.com/git/riazj.com
Log | Files | Refs | LICENSE

git.html (3294B)


      1 <!DOCTYPE html>
      2 <html lang="en">
      3 <head>
      4 <meta charset="utf-8">
      5 <title>Self-Host Git Repositories with Stagit | Riaz's Website</title>
      6 <link rel="stylesheet" href="/style.css">
      7 <link rel="icon" href="data:,">
      8 <meta name="description" content="How to self-host git repositories with stagit on NearlyFreeSpeech">
      9 <meta name="viewport" content="width=device-width, initial-scale=1">
     10 </head>
     11 <body>
     12 <h1>Self-Host Git Repositories with Stagit</h1>
     13 <hr>
     14 <article>
     15 <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>
     16 <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>
     17 <pre>
     18 cd /home/public
     19 mkdir git
     20 cd $_
     21 git init --bare test
     22 </pre>
     23 <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>
     24 <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>
     25 <pre>
     26 $ git clone git://riazj.com/git/riazj.com
     27 Cloning into 'riazj.com'...
     28 fatal: unable to connect to riazj.com:
     29 riazj.com[0: 2607:ff18:80:4::6db8]: errno=No route to host
     30 riazj.com[1: 208.94.117.16]: errno=Network is unreachable
     31 </pre>
     32 <p>Back on the host, install stagit.</p>
     33 <pre>
     34 cd /home/private
     35 git clone git://git.codemadness.org/stagit
     36 cd stagit
     37 make
     38 make install
     39 </pre>
     40 <p>I set PREFIX to ~/stagit in the makefile and ran the command below to include the executables in my PATH.</p>
     41 <pre>echo 'export PATH="/home/private/stagit/bin:$PATH"' &gt;&gt; ~/.zshrc</pre>
     42 <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>
     43 <pre>
     44 echo "Riaz" &gt; owner
     45 echo "test repo" &gt; description
     46 echo "https://riazj.com/git/test" &gt; url
     47 </pre>
     48 <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>
     49 <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>
     50 </article>
     51 <footer>
     52 <hr>
     53 <a href="/">Home Page</a></footer>
     54 </body>
     55 </html>