Installing GIT from source

Git-scm.com is the new home for git.  Download the source code and install in /usr/local

Gitosis is a tool to manage Git repositories. Obtain the latest copy from the repository:

git clone git://eagain.net/gitosis

Installing GIT on RHEL from RPMs

Install the following RPMs:

  • git-all: perl_Git, git-email, emacs-git,git-cvs,git-svn,gitk, git-gui,git
  • gitosis
  • gitweb,
  • qgit,
  • stgit
  • git-daemon
  • xinetd
  • curl-devel   # needed for installing gitweb.cgi from git source

The README.rst included with gitosis and Chapter 11 of Pragmatic Version Control Using Git explain how to install it. On RHEL/CentOS, the gitosis user is created using

useradd --shell /bin/sh --create-home --comment 'git version control'  \
--home /usr/local/lib/gitosis gitosis

Note:  after running

python setup.py install

Make sure to run

chmod +x  /usr/local/lib/gitosis/gitosis/repositories/gitosis-admin.git/hooks/post-update

Otherwise, gitosis will not correctly add each user's public key to ~git/.ssh/authorized_keys

Configuring git daemon

git-daemon can be run by xinetd, by creating the file /etc/xinetd.d/git

# default: off
# description: The git dæmon allows git repositories to be exported using
#	the git:// protocol.

service git
{
        disable		= no
        socket_type     = stream
        wait            = no
        user            = gitosis
        server          = /usr/bin/git-daemon
        server_args     = --base-path=/usr/local/lib/gitosis/repositories --export-all  --syslog --inetd --verbose
        log_on_failure  += USERID
# xinetd doesn't do this by default. bug #195265
        flags		= IPv6
}


Configuring GitWeb

Using a Virtual Host

create a DNS cname (alias) for a hostname that will be used for GitWeb.  Using a Virtual Host seems to be the preferred method of configuring Apache to work with gitweb.cgi

/etc/httpd/conf.d/git.conf

Options +FollowSymLinks

<VirtualHost *:80>
	ServerName eol-git.guest.ucar.edu
	SetEnv GITWEB_CONFIG /etc/gitweb.conf
	ServerAlias eol-git.guest.ucar.edu

	DocumentRoot /var/www/git

	<Directory /var/www/git>
		Options +ExecCGI
		AddHandler cgi-script cgi

		DirectoryIndex gitweb.cgi

		RewriteEngine On
	        RewriteBase /git
		RewriteCond %{REQUEST_FILENAME} !-f
		RewriteCond %{REQUEST_FILENAME} !-d
		RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
	</Directory>
</VirtualHost>

eol-git.guest.ucar.edu:/etc/gitweb.conf  contains:

# Include the global configuration, if found.
# do "/etc/gitweb.conf" if \-e "/etc/gitweb.conf";
# Point to projects.list file generated by gitosis.
# Here gitosis manages the user "git", who has a
# home directory of /srv/example.com/git
$projects_list = "/usr/local/lib/gitosis/repositories";
# Where the actual repositories are located.
$projectroot = "/usr/local/lib/gitosis/repositories";
# By default, gitweb will happily let people browse any repository
# they guess the name of. This may or may not be what you wanted.&nbsp; I
# choose to allow gitweb to show only repositories that git-daemon
# is already sharing anonymously.
$export_ok = "git-daemon-export-ok";
# Alternatively, you could set these, to allow exactly the things in
# projects.list, which in this case is the repos with gitweb=yes
# in gitosis.conf. This means you don't need daemon=yes, but you
# can't have repositories hidden but browsable if you know the name.
# And note gitweb already allows downloading the full repository,
# so you might as well serve git-daemon too.
# $export_ok = "";
# $strict_export = "true";
# A list of base urls where all the repositories can be cloned from.
# Easier than having per-repository cloneurl files.
@git_base_url_list = ('git://eol-git.guest.ucar.edu');
# allow snapshots
$feature{'snapshot'}{'default'} = \[1\];
$feature{'blame'}{'default'} = \[1\];
$feature{'pathinfo'}{'default'} = \[1\];

gitosis.conf needs to enable daemon access for each repository:

[gitosis]
gitweb.snapshot = tbz2,tgz

[group gitosis-admin]
writable = gitosis-admin
owner = vanandel
members = vanandel dennisf


[group chill_par_rec]
writable = chill_par_rec
members = vanandel dennisf
description = CSU CHILL radar data aquisition
owner = vanandel
gitweb = yes
daemon = yes

[repo chill_par_rec]
daemon = yes
gitweb = yes

Without a Virtual Host

gitweb.cgi is installed in /var/www/_git_cgi-bin/

The remaining gitweb support files are installed in /var/www/_gitweb

/etc/httpd/conf.d/git.conf

# map /git/* to call the CGI

ScriptAlias /git "/var/www/_git_cgi-bin/gitweb.cgi"

<Directory "/var/www/_git_cgi-bin">
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

SetEnv      GITWEB_CONFIG   /etc/gitweb.conf

# map references to _gitweb to /var/www/_gitweb - this is where our icons and stylesheets live

Alias /_gitweb/ "/var/www/_gitweb/"
<Directory "/var/www/_gitweb">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
 

/etc/gitweb.conf

$projectroot = '/usr/local/git/repositories/';
$GIT = '/opt/local/bin/git';
$logo_url = "http://git-scm.com";
$my_uri = "/git";
$favicon = "_gitweb/git-favicon.png";
$logo = "_gitweb/git-logo.png";
$stylesheet = "_gitweb/gitweb.css";
$projects_list = "/usr/local/git/repositories";

Modifications to gitweb.cgi

The GITWEB_CONFIG environment variable does not seem to be set by Apache, so we must modify the getweb.cgi script

our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "/etc/gitweb.conf";

Resources

Pragmatic Version Control Using Git

  • No labels