Crear repositorio git con soporte web con apache

Git es un software de sistema de control de versiones de Gestión distribuida, diseñado por Linus Torvalds. Más información: http://es.wikipedia.org/wiki/Git

  • 1.- Conectarnos como root:

    # su
  • 2.- Instalación de paquetes:

    # apt-get install apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common perl git-core gitweb
  • 3.- Añadir usuario al grupo www-data:

    # adduser zital www-data
  • 4.- Crear carpetas para repositorio:

    # mkdir /home/git
    # mkdir /home/git/repo
    # mkdir /home/git/www
  • 5.- Configurar apache: /etc/apache2/sites-evailable/git

    Alias git /home/git/www
    <Directory /home/git/www>
    Allow from all
    AllowOverride all
    Order allow,deny
    Options ExecCGI
    <Files gitweb.cgi>
    SetHandler cgi-script
    </Files>
    </Directory>
    DirectoryIndex gitweb.cgi
    SetEnv  GITWEB_CONFIG  /etc/gitweb.conf

    # ln -s /etc/apache2/sites-evailable/git /etc/apache2/sites-enabled/git
    # ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
    # /etc/init.d/apache2 restart
  • 6.- Configurar git: /etc/gitweb.conf
    # path to git projects (<project>.git)
    $projectroot = "/home/git/repo";

    # directory to use for temp files
    $git_temp = "/tmp";

    # target of the home link on top of all pages
    #$home_link = $my_uri || "/";

    # html text to include at home page
    $home_text = "indextext.html";

    # file with project list; by default, simply scan the projectroot dir.
    $projects_list = $projectroot;

    # stylesheet to use
    $stylesheet = "gitweb.css";

    # logo to use
    $logo = "git-logo.png";

    # the 'favicon'
    $favicon = "git-favicon.png";

  • 6.- Copiar archivos necesarios para acceso web mediante apache:

    # cp /usr/lib/cgi-bin/gitweb.cgi /home/git/www/gitweb.cgi
    # cp /usr/share/gitweb/* /home/git/www
  • 7.- Cambiar de dueño a la carpeta /home/git

    # chown -R zital:www-data /home/git
  • 8.- Cambiar de usuario:

    # su zital
  • 9.- Crear repositorio:

    $ cd /home/git/repo
    $ mkdir project.git
    $ cd project.git
    $ git init
    $ echo "Desscripción del proyecto" > .git/description
    $ git config --global user.name "ZiTAL"
    $ git config --global user.email "zital@esdebian.org"
    $ git commit -a
    $ touch .git/git-daemon-export-ok
  • 10.- Arrancar demonio:

    $ git daemon --base-path=/home/git/repo --detach --syslog --export-all
  • 11.- Obtener proyecto mediante git:

    $ git clone git://IP/project.git project
  • 12.- Listar proyectos mediante URL: http://IP/git

Fuente:
http://www.howtoforge.com/how-to-install-a-public-git-repository-on-a-debian-server