User login

GIT server installation

GIT Server installation

  1. Download an installation CD:

  1. Install the image as a virtual or a real server. Choose a WEB server to be included during the installation. If a virtual server is being installed, create a separate virtual volume for git repositories and attach it to the virtual sever. If installing on a real HW, it is highly recommended to create a separate partition for git data at the installation time (perform custom disk partitioning).
  1. Partition the disk which will contain git repositories. Let us assume it is seen in the system as /dev/sdb device:

$ sudo fdisk /dev/sdb

Command (m for help):

Command action
e extended
p primary partition (1-4)

Partition number (1-4):

$ sudo mkfs.ext4 /dev/sdb1

$ sudo mkdir /srv

$ sudo mount /dev/sdb1 /srv/

  1. Make the git partition automounted by adding the following line to /etc/fstab:

/dev/sdb1 /srv ext4 defaults 0 0

  1. Install git and gitweb (for git: protocol support):

sudo apt-get install git
sudo apt-get install gitweb

  1. Create the folder structure on the git partition:

sudo mkdir /srv/git
sudo mkdir /srv/git/pub

  1. Create the git user:

sudo adduser git

Note: this user is for use in the public git repository only. Public git repository provides free access for git user (with write permission). All repositories which need limited write access will be placed under /srv/git structure with corresponding owner and permissions.

  1. Make pub/ directory owned by the (public) git user:

sudo chown -R git:git /srv/git/pub

  1. Open gitweb configuration file:

sudo vi /etc/gitweb.conf file, $projectroot)

  1. Check the it looks like:

# path to git projects (<project>.git)
$projectroot = "/var/cache/git";

# 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
@stylesheets = ("/git/static/gitweb.css");

# javascript code for gitweb
#$javascript = "static/gitweb.js";

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

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

# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();

  1. Open in the same manner /etc/apache2/conf.d/gitweb and check it contains:

Alias /gitweb /var/www/git

<Directory /var/www/git>
Options FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
Allow from 10.10
Allow from 192.168
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf

  1. Make a symbolic link from the git partition to the gitweb root:

sudo ln -s /srv/git /var/cache/git

  1. Create the git WEB server area:

sudo mkdir /var/www/git

  1. Copy content of gitweb share folder to the git WEB server area:

cd /usr/share/gitweb/
cp -r * /var/www/git/
sudo chown -R git:git /var/www/git

  1. Restart the apache WEB server:

sudo /etc/init.d/apache2 restart

  1. For the git daemon to start automatically add the following line to /etc/rc.local:

sudo -u git git daemon --base-path=/var/cache/git --detach --syslog --export-all

Now time to place your repositories at proper places. For example create a private folder for user 'alex' and place a copy of the repository there from a server named <foreign>:

adduser alex
su -l alex
cd /srv/git/
sudo mkdir alex
sudo chown alex:alex alex
cd alex
mkdir cm
cd cm
git init
git fetch myusername@foreign:/git/pub/

Now let us create a public cm repository and clone data to it from the private alex's cm repo created previously:

su -l git
cd /srv/git/pub
mkdir cm
git init
git clone /srv/git/alex/cm