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 \
git
Setup SSH
On you own account, copy your public key to the /tmp directory
ssh-keygen -t rsa
cd ~/.ssh
mv id_rsa.pub gitolite.pub
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/gitolite.pub /tmp/local.pub
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/local.pub
Back to your user and setup the user details
git config --global user.email "rob@muggridge.org"
git config --global user.name "Rob Muggridge"
Now configure gitolite
mkdir ~/git
cd ~/git
git clone gitolite:gitolite-admin.git
mkdir gitolite-admin/keydir/homer
cp /tmp/local.pub gitolite-admin/keydir/homer/rob.pub
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
Configure
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
References
Setting up a gitolite server in Ubuntu
Git on the Server – Gitolite
Ubuntu 12.04 – Installing Gitolite and Gitweb