{"id":400,"date":"2017-11-30T12:25:12","date_gmt":"2017-11-30T12:25:12","guid":{"rendered":"https:\/\/www.micha.name\/blog\/?p=400"},"modified":"2017-11-30T12:32:38","modified_gmt":"2017-11-30T12:32:38","slug":"gitolite-and-gitweb","status":"publish","type":"post","link":"https:\/\/www.micha.name\/blog\/2017\/11\/30\/gitolite-and-gitweb\/","title":{"rendered":"Gitolite and GitWeb on Debian 9"},"content":{"rendered":"<p>Time to move my personal git repositories onto my VPS.<\/p>\n<p>To this end I installed and configured <a href=\"http:\/\/gitolite.com\">gitolite3 <\/a>and <a href=\"https:\/\/git-scm.com\/docs\/gitweb\">gitweb <\/a>on Debian 9.<\/p>\n<hr \/>\n<h2>gitolite<\/h2>\n<p>The gitolite install is simply &#8220;apt-get install gitolite3&#8221;, and specify an ssh public key as the admin key. I then tweaked it as follows:<\/p>\n<ul>\n<li>renamed the\u00a0<em>gitolite3<\/em> user to\u00a0<em>git<\/em> (by directly editing \/etc\/passwd etc.)<\/li>\n<li>Edited <code>\/etc\/gitolite3\/gitolite.rc<\/code><br \/>\nas follows:<\/p>\n<ul>\n<li>changed UMASK to 027 (for gitweb)<\/li>\n<li>enabled the &#8216;create&#8217;, &#8216;fork&#8217;, &#8216;readme&#8217;, and &#8216;D&#8217; commands<\/li>\n<li>enabled the &#8216;no-auto-create&#8217; setting<\/li>\n<\/ul>\n<\/li>\n<li>Changed permissions in <code>\/var\/lib\/gitolite3<\/code><br \/>\n(for gitweb):<\/p>\n<ul>\n<li><code>chmod g+rX repositories<\/code><\/li>\n<li><code>chmod g+rX repositories\/*<\/code><\/li>\n<li><code>chmod g+r projects.list<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>I then cloned the <em>gitolite-admin<\/em> repository and added my users and groups.<\/p>\n<p>To set up access for gitweb, I added the following special rule which exposes all repositories to gitweb as well as a rule to hide any secret repositories (simply add them to the @secret group)<\/p>\n<pre>repo\u00a0@all\r\n    R = daemon gitweb\r\n\r\nrepo @secret\r\n    - = daemon gitweb\r\n    option deny-rules = 1\r\n<\/pre>\n<p>The only issue I had was trying to track down how to prevent wild repositories being created on every clone request. No amount of searching gave me an answer, but it helps to read the comments in the configuration files..<\/p>\n<hr \/>\n<h2>gitweb<\/h2>\n<p>The gitweb install was similarly painless; &#8220;apt-get install gitweb&#8221; and then :<\/p>\n<ul>\n<li>add www-data user to the git group\n<ul>\n<li>adduser www-data git<\/li>\n<\/ul>\n<\/li>\n<li>edit <code>\/etc\/gitweb.conf<\/code>:\n<ul>\n<li>$projectroot = &#8220;\/var\/lib\/gitolite3\/repositories&#8221;;<\/li>\n<li>$projects_list = &#8220;\/var\/lib\/gitolite3\/projects.list&#8221;;<\/li>\n<li>$export_ok = &#8220;git-daemon-export-ok&#8221;;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>I also set up some the site name and extra breadcrumbs and a home-link for nicer navigation back to the system homepage.<\/p>\n<p>I left the default Debian integration with apache, which adds a &#8216;\/gitweb&#8217; endpoint. I also had a vhost configuration but didn&#8217;t use it.<\/p>\n<hr \/>\n<h2>Import \/ migrate old repositories<\/h2>\n<p>Finally time to migrate my old gitolite2 repositories, which was a bit more involved as I no longer have the gitolite2 server running.<\/p>\n<p>Luckily there&#8217;s a good set of <a href=\"http:\/\/gitolite.com\/gitolite\/basic-admin\/#appendix-1-bringing-existing-repos-into-gitolite\">step-by-step instructions<\/a> on the gitolite homepage.<\/p>\n<p>Basically, copy the bare repository into &lt;code&gt;\/var\/lib\/gitolite3\/repositories&lt;\/code&gt;, ensure the permissions are correct, run\u00a0&lt;code&gt;gitolite setup&lt;\/code&gt; to\u00a0fix the git state, and finally add any normal repositories to your gitolite-admin configuration.<\/p>\n<h3>normal repositories<\/h3>\n<p>Copy the repositories into &lt;code&gt;\/var\/lib\/gitolite3\/repositories&lt;\/code&gt; and manually add them to the\u00a0 gitolite configuration.<\/p>\n<h3>wild repositories<\/h3>\n<p>Copy them into the repositories directory ensuring they are in the correct place based on your configuration, then add a &#8216;gl-creator&#8217; file which has to consist of the name of the user which created the repository.<\/p>\n<p>In my case there was already a &#8216;gl-creater&#8217; file in each repo, so I simply renamed them to &#8216;gl-creator&#8217;:<\/p>\n<pre>find . -name \"gl-creater\" -execdir mv gl-creater gl-creator \\;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Install and configure gitolite and gitweb on Debian 9 &#8216;stretch&#8217;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,56,29],"tags":[12,21,62,66,65,30,64],"_links":{"self":[{"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/posts\/400"}],"collection":[{"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/comments?post=400"}],"version-history":[{"count":3,"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":403,"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions\/403"}],"wp:attachment":[{"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/media?parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/categories?post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.micha.name\/blog\/wp-json\/wp\/v2\/tags?post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}