Ok the gitweb part:
you have to install the package gitweb sudo apt-get install gitweb
Then you have to edit the apache gitweb config file
$EDITOR /etc/apache2/conf.d/gitweb
change the line Alias /gitweb /usr/share/gitweb
to
Alias /git /usr/share/gitweb
open the /etc/gitweb.conf file:
you have to change the line
$projectroot ".." to
$projectroot "/code/git"
and change any other line containing /gitweb to /git
for example
$stylesheet = "/gitweb/gitweb.css";
to $stylesheet = "/git/gitweb.css";
then reload you apache webserver with sudo /etc/init.d/apache2 force-reload
The GIT part itself:
I STRONGLY recommend the use of gitosis (http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way)
REMEMBER if you use gitosis the line $projectroot in /etc/gitweb.conf has to be $projectroot = "/home/git/repositories/";
You can find detailed information on howto setup gitosis at
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
describing the full gitosis setup is too long for this answere.
If you need more help on gitosis drop me a comment
EDIT:
it might be neccessary to issue usermod -a -G git www-data and a
cd /home/git/repositories ; chgrp -R git *
to fix apache permission problems.