Difference between revisions of "Gitweb"

From ArchWiki
Jump to: navigation, search
(Syntax highlighting: Added section on how to enable syntax highlighting.)
m (Small spelling and formatting fixes.)
Line 6: Line 6:
 
  pacman -S git apache
 
  pacman -S git apache
  
Next you need to link the current gitweb default to your webserver location. In this example i use the default folder locations:
+
Next you need to link the current gitweb default to your webserver location. In this example I use the default folder locations:
 
  ln -s /usr/share/gitweb /srv/http/gitweb
 
  ln -s /usr/share/gitweb /srv/http/gitweb
  
Line 40: Line 40:
  
 
===Gitweb config===
 
===Gitweb config===
Next we need to make a gitweb config file. Open (or create if not existing) the file /etc/conf.d/gitweb.conf and place this in it:
+
Next we need to make a gitweb config file. Open (or create if it does not exist) the file {{Filename|/etc/conf.d/gitweb.conf}} and place this in it:
<pre>
+
{{hc|/etc/conf.d/gitweb.conf|<nowiki>
 
$git_temp = "/tmp";
 
$git_temp = "/tmp";
  
Line 49: Line 49:
 
# Base URLs for links displayed in the web interface.
 
# Base URLs for links displayed in the web interface.
 
our @git_base_url_list = qw(git://<your_server> http://git@<your_server>);  
 
our @git_base_url_list = qw(git://<your_server> http://git@<your_server>);  
</pre>
+
</nowiki>}}
  
 
Now the the configuration is done, please restart your webserver.
 
Now the the configuration is done, please restart your webserver.
Line 69: Line 69:
  
 
==Adding repositories==
 
==Adding repositories==
To add a repository go to your repository folder. There make your repository like so:
+
To add a repository go to your repository folder, make your repository like so:
 
  mkdir my_repository.git
 
  mkdir my_repository.git
 
  git init --bare my_repository.git/
 
  git init --bare my_repository.git/
Line 86: Line 86:
 
That is all for making a repository. You can now see it on your http://localhost/gitweb (assuming everything went fine). You do not need to restart apache for new repositories since the gitweb cgi script simply reads your repository folder.
 
That is all for making a repository. You can now see it on your http://localhost/gitweb (assuming everything went fine). You do not need to restart apache for new repositories since the gitweb cgi script simply reads your repository folder.
  
==Thanx to...==
+
==Thanks to...==
 
This howto was mainly based on the awesome howto from howtoforge: http://www.howtoforge.com/how-to-install-a-public-git-repository-on-a-debian-server I only picked the parts that are needed to get it working and left the additional things out.
 
This howto was mainly based on the awesome howto from howtoforge: http://www.howtoforge.com/how-to-install-a-public-git-repository-on-a-debian-server I only picked the parts that are needed to get it working and left the additional things out.

Revision as of 00:12, 16 November 2011

Gitweb is the default web interface provided with git itself and is the basis for other git scripts like cgit, gitosis and others.

Installation

To install gitweb you first have to install git and a webserver. For this example we use apache but you can also use others:

pacman -S git apache

Next you need to link the current gitweb default to your webserver location. In this example I use the default folder locations:

ln -s /usr/share/gitweb /srv/http/gitweb

That's it for the "installation". Next is the configuration.

Configuration

Apache

Add the following to the end of you /etc/httpd/conf/httpd.conf

<Directory "/srv/http/gitweb">
   DirectoryIndex gitweb.cgi
   Allow from all
   AllowOverride all
   Order allow,deny
   Options ExecCGI
   <Files gitweb.cgi>
   SetHandler cgi-script
   </Files>
   SetEnv  GITWEB_CONFIG  /etc/conf.d/gitweb.conf
</Directory>

You can put the configuration in it's own config file in /etc/httpd/conf/extra/ but that's up to you to decide.

Lighttpd

If you're using lighttpd, make sure mod_alias, mod_redirect, mod_cgi and mod_setenv are loaded. Add the following to /etc/lighttpd/lighttpd.conf:

server.modules += ( mod_setenv )
setenv.add-environment = ( "GITWEB_CONFIG" => "/etc/conf.d/gitweb.conf" )
url.redirect += ( "^/gitweb$" => "/gitweb/" )
alias.url += ( "/gitweb/" => "/usr/share/gitweb/" )
$HTTP["url"] =~ "^/gitweb/" {
       cgi.assign = (".cgi" => "")
       server.indexfiles = ("gitweb.cgi")
}

Gitweb config

Next we need to make a gitweb config file. Open (or create if it does not exist) the file Template:Filename and place this in it:

/etc/conf.d/gitweb.conf
$git_temp = "/tmp";

# The directories where your projects are. Must not end with a slash.
$projectroot = "/path/to/your/repositories"; 

# Base URLs for links displayed in the web interface.
our @git_base_url_list = qw(git://<your_server> http://git@<your_server>); 

Now the the configuration is done, please restart your webserver. For apache:

/etc/rc.d/httpd restart

Or for lighttpd:

/etc/rc.d/lighttpd restart

Syntax highlighting

To enable syntax highlighting with Gitweb, you have to first install the highlight package from [community]:

pacman -S highlight

When highlight has been installed, simply add this line to your Template:Filename:

$feature{'highlight'}{'default'} = [1];

Save the file and highlighting should now be enabled.

Adding repositories

To add a repository go to your repository folder, make your repository like so:

mkdir my_repository.git
git init --bare my_repository.git/
cd my_repository.git/
touch git-daemon-export-ok
echo "Short project's description" > description

Next open the "config" file and add this:

[gitweb]
        owner = Your Name

This will fill in the "Owner" field in gitweb. It's not required.

I assumed that you want to have this repository as "central" repository storage where you push your commits to so the git-daemon-export-ok and --bare are here to have minimal overhead and to allow the git daemon to be used on it.

That is all for making a repository. You can now see it on your http://localhost/gitweb (assuming everything went fine). You do not need to restart apache for new repositories since the gitweb cgi script simply reads your repository folder.

Thanks to...

This howto was mainly based on the awesome howto from howtoforge: http://www.howtoforge.com/how-to-install-a-public-git-repository-on-a-debian-server I only picked the parts that are needed to get it working and left the additional things out.