From ArchWiki
Revision as of 13:32, 25 September 2010 by EVRAMP (talk | contribs) (Git daemon: rewritten to use git-daemon rc.d script)
Jump to: navigation, search

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


To install gitweb you fitst 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 copy the current gitweb default to your webserver location. In this example i use the default folder locations:

cp -R /usr/share/gitweb/ /srv/http/

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


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
   SetEnv  GITWEB_CONFIG  /etc/conf.d/gitweb.conf

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

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:

$projectroot = "/path/to/your/repositories";
$git_temp = "/tmp";
$projects_list = $projectroot;

Be sure to change the "/path/to/your/repositories" to the path you want your repositories in.

Now the the configuration is done, please restart apache by executing:

/etc/rc.d/httpd restart

Adding repositories

To add a repository go to your repository folder. There 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:

        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 don't need to restart apache for new repositories since the gitweb cgi script simply reads your repository folder.

Git daemon

This will allow url's like "git clone git://localhost/my_repository.git". Do know that this git:// protocol is read only!

Edit configuration file for git-dameon /etc/conf.d/git-daemon.conf (GIT_REPO is a place with your git projects), then start git-daemon with root privileges:

/etc/rc.d/git-daemon start

To run the git-daemon every time at boot, just append git-deamon to DAEMONS line in /etc/rc.conf file.

Now you can simply use:

git clone git://localhost/my_repository.git

Thanx to...

This howto was mainly based on the awesome howto from howtoforge: I only picked the parts that are needed to get it working and left the additional things out.