Git Administration

Setting up a Git repository master on your own servers, using gitolite for access and gitweb as a web front end.

Installing Git

sudo add-apt-repository ppa:git-core/ppa 
sudo apt-get update 
sudo apt-get install git

Setup the user

sudo adduser \
 --system \
 --shell /bin/bash \
 --gecos 'git version control' \
 --group \
 --disabled-password \
 --home /mnt/apps/git \

Setup SSH

On you own account, copy your public key to the /tmp directory

ssh-keygen -t rsa
cd ~/.ssh
mv id_rsa gitolite
vi config
host gitolite
user git # replace it by the actual git user for the gitolite server
hostname homer
identityfile ~/.ssh/gitolite
cp ~/.ssh/ /tmp/

Now change to the git user
Note, gl-setup gets us temporary admin access!

sudo su git
echo "PATH=$HOME/bin:$PATH" > ~/.bashrc
gl-setup /tmp/

Back to your user and setup the user details

git config --global ""
git config --global "Rob Muggridge"

Now configure gitolite

mkdir ~/git
cd ~/git
git clone gitolite:gitolite-admin.git
mkdir gitolite-admin/keydir/homer
cp /tmp/ gitolite-admin/keydir/homer/
vi gitolite-admin/conf/gitolite.conf
repo gitolite-admin
RW+ = local
repo testing
RW+ = @all
repo mynewrepo
RW+ = myusername

Now commit the changes (repo should be automatically created)

cd ~/git/gitolite-admin
git add -A
git commit -m 'New user keys and new repository.'
git push origin master

Setting up gitweb

sudo apt-get install highlight gitweb


sudo vi /etc/gitweb.conf
# change $projectroot to /home/git/repositories
# change $projects_list to /home/git/projects.list
# Add Highlighting at the end
$feature{'highlight'}{'default'} = [1];

Change gitolite instance to allow access for gitweb.

sudo usermod -a -G git www-data
sudo chmod g+r /mnt/apps/git/projects.list
sudo chmod -R g+rx /mnt/apps/git/repositories
sudo service apache2 restart


Setting up a gitolite server in Ubuntu
Git on the Server – Gitolite
Ubuntu 12.04 – Installing Gitolite and Gitweb