diff options
Diffstat (limited to 'docs/posts/self-hosting_git')
-rw-r--r-- | docs/posts/self-hosting_git/index.html | 67 |
1 files changed, 52 insertions, 15 deletions
diff --git a/docs/posts/self-hosting_git/index.html b/docs/posts/self-hosting_git/index.html index f41a591..d927e95 100644 --- a/docs/posts/self-hosting_git/index.html +++ b/docs/posts/self-hosting_git/index.html | |||
@@ -28,7 +28,7 @@ | |||
28 | 17/10 — 2020 | 28 | 17/10 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 87.90 | 31 | 87.91 |
32 | </span> | 32 | </span> |
33 | <span class="stats-unit">cm</span> | 33 | <span class="stats-unit">cm</span> |
34 |   | 34 |   |
@@ -42,11 +42,21 @@ | |||
42 | Self-hosting Git | 42 | Self-hosting Git |
43 | </h1> | 43 | </h1> |
44 | <div class="post-text"> | 44 | <div class="post-text"> |
45 | <p>Earlier this week, I began migrating my repositories from Github to <a href="https://git.zx2c4.com/cgit/about/">cgit</a>. If you care at all about big corporates turning open-source into a T-shirt farming service, this is the way to go.</p> | 45 | <p>Earlier this week, I began migrating my repositories from Github to |
46 | <a href="https://git.zx2c4.com/cgit/about/">cgit</a>. If you care at all | ||
47 | about big corporates turning open-source into a T-shirt farming service, | ||
48 | this is the way to go.</p> | ||
46 | <h3 id="offerings">Offerings</h3> | 49 | <h3 id="offerings">Offerings</h3> |
47 | <p>cgit is <em>very</em> bare bones. It is <a href="https://tools.ietf.org/html/rfc3875">cgi-based</a> web interface to git, and nothing more. You may browse repositories, view diffs, commit logs and even clone via http. If you are looking to replace Github with cgit, keep in mind that cgit does not handle issues or pull/merge requests. If people wish to contribute to your work, they would have to send you a patch via email.</p> | 50 | <p>cgit is <em>very</em> bare bones. It is <a |
51 | href="https://tools.ietf.org/html/rfc3875">cgi-based</a> web interface | ||
52 | to git, and nothing more. You may browse repositories, view diffs, | ||
53 | commit logs and even clone via http. If you are looking to replace | ||
54 | Github with cgit, keep in mind that cgit does not handle issues or | ||
55 | pull/merge requests. If people wish to contribute to your work, they | ||
56 | would have to send you a patch via email.</p> | ||
48 | <h3 id="setup">Setup</h3> | 57 | <h3 id="setup">Setup</h3> |
49 | <p>Installing cgit is fairly straightforward, if you would like to compile it from source:</p> | 58 | <p>Installing cgit is fairly straightforward, if you would like to |
59 | compile it from source:</p> | ||
50 | <div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># fetch</span></span> | 60 | <div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># fetch</span></span> |
51 | <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> clone https://git.zx2c4.com <span class="kw">&&</span> <span class="bu">cd</span> cgit</span> | 61 | <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> clone https://git.zx2c4.com <span class="kw">&&</span> <span class="bu">cd</span> cgit</span> |
52 | <span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> submodule init</span> | 62 | <span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> submodule init</span> |
@@ -55,9 +65,16 @@ | |||
55 | <span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co"># install</span></span> | 65 | <span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co"># install</span></span> |
56 | <span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> NO_LUA=1</span> | 66 | <span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> NO_LUA=1</span> |
57 | <span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> make install</span></code></pre></div> | 67 | <span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> make install</span></code></pre></div> |
58 | <p>This would drop the cgit cgi script (and the default css) into <code>/var/www/htdocs/cgit</code>. You may configure cgit by editing <code>/etc/cgitrc</code>. I specify the <code>NO_LUA</code> flag to compile without lua support, exclude that flag if you would like to extend cgit via lua scripts.</p> | 68 | <p>This would drop the cgit cgi script (and the default css) into |
69 | <code>/var/www/htdocs/cgit</code>. You may configure cgit by editing | ||
70 | <code>/etc/cgitrc</code>. I specify the <code>NO_LUA</code> flag to | ||
71 | compile without lua support, exclude that flag if you would like to | ||
72 | extend cgit via lua scripts.</p> | ||
59 | <h3 id="going-live">Going live</h3> | 73 | <h3 id="going-live">Going live</h3> |
60 | <p>You might want to use, <a href="https://github.com/gnosek/fcgiwrap">fcgiwrap</a>, a <a href="http://www.nongnu.org/fastcgi">fastcgi</a> wrapper for <code>cgi</code> scripts,</p> | 74 | <p>You might want to use, <a |
75 | href="https://github.com/gnosek/fcgiwrap">fcgiwrap</a>, a <a | ||
76 | href="http://www.nongnu.org/fastcgi">fastcgi</a> wrapper for | ||
77 | <code>cgi</code> scripts,</p> | ||
61 | <div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install fcgiwrap</span> | 78 | <div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install fcgiwrap</span> |
62 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> systemctl start fcgiwrap.socket</span></code></pre></div> | 79 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> systemctl start fcgiwrap.socket</span></code></pre></div> |
63 | <p>Expose the cgit cgi script to the web via <code>nginx</code>:</p> | 80 | <p>Expose the cgit cgi script to the web via <code>nginx</code>:</p> |
@@ -81,15 +98,21 @@ server { | |||
81 | <p>Point cgit to your git repositories:</p> | 98 | <p>Point cgit to your git repositories:</p> |
82 | <pre><code># /etc/cgitrc | 99 | <pre><code># /etc/cgitrc |
83 | scan-path=/path/to/git/repos</code></pre> | 100 | scan-path=/path/to/git/repos</code></pre> |
84 | <p><strong><em>Note</em></strong>: <em><code>scan-path</code> works best if you stick it at the end of your <code>cgitrc</code></em>.</p> | 101 | <p><strong><em>Note</em></strong>: <em><code>scan-path</code> works best |
85 | <p>You may now create remote repositories at <code>/path/to/git/repos</code>, via:</p> | 102 | if you stick it at the end of your <code>cgitrc</code></em>.</p> |
103 | <p>You may now create remote repositories at | ||
104 | <code>/path/to/git/repos</code>, via:</p> | ||
86 | <pre><code>git init --bare</code></pre> | 105 | <pre><code>git init --bare</code></pre> |
87 | <p>Add the remote to your local repository:</p> | 106 | <p>Add the remote to your local repository:</p> |
88 | <pre><code>git remote set-url origin user@remote:/above/path | 107 | <pre><code>git remote set-url origin user@remote:/above/path |
89 | git push origin master</code></pre> | 108 | git push origin master</code></pre> |
90 | <h3 id="configuration">Configuration</h3> | 109 | <h3 id="configuration">Configuration</h3> |
91 | <p>cgit is fairly easy to configure, all configuration options can be found <a href="https://git.zx2c4.com/cgit/tree/cgitrc.5.txt">in the manual</a>, here are a couple of cool ones though:</p> | 110 | <p>cgit is fairly easy to configure, all configuration options can be |
92 | <p><strong>enable-commit-graph</strong>: Generates a text based graphical representation of the commit history, similar to <code>git log --graph --oneline</code>.</p> | 111 | found <a href="https://git.zx2c4.com/cgit/tree/cgitrc.5.txt">in the |
112 | manual</a>, here are a couple of cool ones though:</p> | ||
113 | <p><strong>enable-commit-graph</strong>: Generates a text based | ||
114 | graphical representation of the commit history, similar to | ||
115 | <code>git log --graph --oneline</code>.</p> | ||
93 | <pre><code>| * | Add support for configuration file | 116 | <pre><code>| * | Add support for configuration file |
94 | * | | simplify command parsing logic | 117 | * | | simplify command parsing logic |
95 | * | | Refactor parsers | 118 | * | | Refactor parsers |
@@ -110,7 +133,11 @@ git push origin master</code></pre> | |||
110 | | | * | Merge branch 'fix/duplicate-habits' | 133 | | | * | Merge branch 'fix/duplicate-habits' |
111 | | | |\ \ | 134 | | | |\ \ |
112 | | | | * | move duplicate check to command parsing blo...</code></pre> | 135 | | | | * | move duplicate check to command parsing blo...</code></pre> |
113 | <p><strong>section-from-path</strong>: This option paired with <code>scan-path</code> will automatically generate sections in your cgit index page, from the path to each repo. For example, the directory structure used to generate sections on <a href="https://git.peppe.rs">my cgit instance</a> looks like this:</p> | 136 | <p><strong>section-from-path</strong>: This option paired with |
137 | <code>scan-path</code> will automatically generate sections in your cgit | ||
138 | index page, from the path to each repo. For example, the directory | ||
139 | structure used to generate sections on <a href="https://git.peppe.rs">my | ||
140 | cgit instance</a> looks like this:</p> | ||
114 | <pre><code>├── cli | 141 | <pre><code>├── cli |
115 | │ ├── dijo | 142 | │ ├── dijo |
116 | │ ├── eva | 143 | │ ├── eva |
@@ -134,11 +161,18 @@ git push origin master</code></pre> | |||
134 | └── web | 161 | └── web |
135 | └── isostatic</code></pre> | 162 | └── isostatic</code></pre> |
136 | <h3 id="ease-of-use">Ease of use</h3> | 163 | <h3 id="ease-of-use">Ease of use</h3> |
137 | <p>As I mentioned before, <code>cgit</code> is simply a view into your git repositories, you will have to manually create new repositories by entering your remote and using <code>git init --bare</code>. Here are a couple of scripts I wrote to perform actions on remotes, think of it as a smaller version of Github’s <code>gh</code> program.</p> | 164 | <p>As I mentioned before, <code>cgit</code> is simply a view into your |
138 | <p>You may save these scripts as <code>git-script-name</code> and drop them in your <code>$PATH</code>, and git will automatically add an alias called <code>script-name</code>, callable via:</p> | 165 | git repositories, you will have to manually create new repositories by |
166 | entering your remote and using <code>git init --bare</code>. Here are a | ||
167 | couple of scripts I wrote to perform actions on remotes, think of it as | ||
168 | a smaller version of Github’s <code>gh</code> program.</p> | ||
169 | <p>You may save these scripts as <code>git-script-name</code> and drop | ||
170 | them in your <code>$PATH</code>, and git will automatically add an alias | ||
171 | called <code>script-name</code>, callable via:</p> | ||
139 | <pre><code>git script-name</code></pre> | 172 | <pre><code>git script-name</code></pre> |
140 | <h4 id="git-new-repo">git-new-repo</h4> | 173 | <h4 id="git-new-repo">git-new-repo</h4> |
141 | <p>Creates a new repository on your remote, the first arg may be a path (section/repo-name) or just the repo name:</p> | 174 | <p>Creates a new repository on your remote, the first arg may be a path |
175 | (section/repo-name) or just the repo name:</p> | ||
142 | <pre><code>#! /usr/bin/env bash | 176 | <pre><code>#! /usr/bin/env bash |
143 | # | 177 | # |
144 | # usage: | 178 | # usage: |
@@ -155,7 +189,10 @@ fi | |||
155 | 189 | ||
156 | ssh user@remote git init --bare "$1";</code></pre> | 190 | ssh user@remote git init --bare "$1";</code></pre> |
157 | <h4 id="git-set-desc">git-set-desc</h4> | 191 | <h4 id="git-set-desc">git-set-desc</h4> |
158 | <p>To set a one line repository description. It simply copies the local <code>.git/description</code>, into <code>remote/description</code>. <code>cgit</code> displays the contents of this file on the index page:</p> | 192 | <p>To set a one line repository description. It simply copies the local |
193 | <code>.git/description</code>, into <code>remote/description</code>. | ||
194 | <code>cgit</code> displays the contents of this file on the index | ||
195 | page:</p> | ||
159 | <pre><code>#! /usr/bin/env bash | 196 | <pre><code>#! /usr/bin/env bash |
160 | # | 197 | # |
161 | # usage: | 198 | # usage: |