epubjs
Version:
Render ePub documents in the browser, across many devices
58 lines (45 loc) • 4.34 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pro Git - professional version control</title>
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
<link href="stylesheet.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }</style>
</head>
<body class="calibre">
<h2 class="calibre4" id="calibre_pb_35">GitWeb</h2>
<p class="calibre3">Now that you have basic read/write and read-only access to your project, you may want to set up a simple web-based visualizer. Git comes with a CGI script called GitWeb that is commonly used for this. You can see GitWeb in use at sites like <code class="calibre10">http://git.kernel.org</code> (see Figure 4-1).</p>
<p class="calibre3"><img src="18333fig0401-tn.png" alt="Figure 4-1. The GitWeb web-based user interface." title="Figure 4-1. The GitWeb web-based user interface." class="calibre6"/></p>
<p class="calibre3">If you want to check out what GitWeb would look like for your project, Git comes with a command to fire up a temporary instance if you have a lightweight server on your system like <code class="calibre10">lighttpd</code> or <code class="calibre10">webrick</code>. On Linux machines, <code class="calibre10">lighttpd</code> is often installed, so you may be able to get it to run by typing <code class="calibre10">git instaweb</code> in your project directory. If you're running a Mac, Leopard comes preinstalled with Ruby, so <code class="calibre10">webrick</code> may be your best bet. To start <code class="calibre10">instaweb</code> with a non-lighttpd handler, you can run it with the <code class="calibre10">--httpd</code> option.</p>
<pre class="calibre9"><code class="calibre10">$ git instaweb --httpd=webrick
[2009-02-21 10:02:21] INFO WEBrick 1.3.1
[2009-02-21 10:02:21] INFO ruby 1.8.6 (2008-03-03) [universal-darwin9.0]
</code></pre>
<p class="calibre3">That starts up an HTTPD server on port 1234 and then automatically starts a web browser that opens on that page. It's pretty easy on your part. When you're done and want to shut down the server, you can run the same command with the <code class="calibre10">--stop</code> option:</p>
<pre class="calibre9"><code class="calibre10">$ git instaweb --httpd=webrick --stop
</code></pre>
<p class="calibre3">If you want to run the web interface on a server all the time for your team or for an open source project you're hosting, you'll need to set up the CGI script to be served by your normal web server. Some Linux distributions have a <code class="calibre10">gitweb</code> package that you may be able to install via <code class="calibre10">apt</code> or <code class="calibre10">yum</code>, so you may want to try that first. We'll walk though installing GitWeb manually very quickly. First, you need to get the Git source code, which GitWeb comes with, and generate the custom CGI script:</p>
<pre class="calibre9"><code class="calibre10">$ git clone git://git.kernel.org/pub/scm/git/git.git
$ cd git/
$ make GITWEB_PROJECTROOT="/opt/git" \
prefix=/usr gitweb/gitweb.cgi
$ sudo cp -Rf gitweb /var/www/
</code></pre>
<p class="calibre3">Notice that you have to tell the command where to find your Git repositories with the <code class="calibre10">GITWEB_PROJECTROOT</code> variable. Now, you need to make Apache use CGI for that script, for which you can add a VirtualHost:</p>
<pre class="calibre9"><code class="calibre10"><VirtualHost *:80>
ServerName gitserver
DocumentRoot /var/www/gitweb
<Directory /var/www/gitweb>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
</Directory>
</VirtualHost>
</code></pre>
<p class="calibre3">Again, GitWeb can be served with any CGI capable web server; if you prefer to use something else, it shouldn't be difficult to set up. At this point, you should be able to visit <code class="calibre10">http://gitserver/</code> to view your repositories online, and you can use <code class="calibre10">http://git.gitserver</code> to clone and fetch your repositories over HTTP.</p>
</body>
</html>