http://computercamp.cdwilson.us/git-gitolite-git-daemon-gitweb-setup-on-ubunt
http://www.ossxp.com/doc/git/gitolite.html
http://blog.airmio.com/2012/05/install-git-server-on-ubuntu-12/
git setup
Install git and doc:
sudo apt-get install git-core git-doc
Setup your username and email:
git config --global user.name "Your Name" git config --global user.email [email protected]
gitolite setup
gitolite uses ssh keys to manage access to the git repositories. In the following steps, we set up gitolite to initialize its admin repository with your public key.
Copy over your pubkey from your local machine to the git server:
# FROM YOUR LOCAL MACHINE scp ~/.ssh/id_rsa.pub git.server:/tmp/your-username-goes-here.pub
Create gitolite
group and gitolite
user:
sudo addgroup gitolite sudo adduser --disabled-password --home /home/gitolite --ingroup gitolite gitolite
Install gitolite:
sudo apt-get -y install gitolite
Append www-data to gitolite group so gitweb can access the repos:
sudo usermod -a -G gitolite www-data
and make sure that groups are updated for apache:
sudo service apache2 restart
Run the gitolite setup:
sudo su - gitolite gl-setup /tmp/your-username-goes-here.pub
Setup will allow you to modify gitolite config umask settings so that new repos are given permissions to enable gitweb and git-daemon export:
# change $REPO_UMASK = 0077; to $REPO_UMASK = 0027; # gets you 'rwxr-x---'
If for some reason you weren’t able to edit .gitolite.rc
during the gl-setup
phase, edit .gitolite.rc
and fix permissions so that gitolite
group has read access to repositories:
emacs /home/gitolite/.gitolite.rc # change $REPO_UMASK = 0077; to $REPO_UMASK = 0027; # gets you 'rwxr-x---' chmod g+r /home/gitolite/projects.list chmod -R g+rx /home/gitolite/repositories
Exit out of gitolite user session and return to your normal user account:
exit
You should now be able to clone the gitolite-admin.git
repository that’s created automatically by the gitolite setup script:
# FROM YOUR LOCAL MACHINE git clone [email protected]:gitolite-admin.git
Edit gitolite.conf
to enable gitweb
and git-daemon
export for testing:
# FROM YOUR LOCAL MACHINE cd gitolite-admin emacs conf/gitolite.conf # change to: repo testing RW+ = @all R = daemon testing "Owner" = "Test repo" git add conf/gitolite.conf git commit -m "Enabled gitweb and git-daemon export for testing repo" git push cd ..
Setting the repo owner and description automatically gives read access to gitweb so you don’t have to specify it explicitly.
Clone testing
and add a file (so it’s not empty):
git clone [email protected]:testing.git cd testing echo "README" > README git add README git commit -m "Added README" git push origin master
gitweb setup
Install gitweb:
sudo apt-get install highlight gitweb
Change the gitweb configuration to use the gitolite repo paths:
sudo emacs /etc/gitweb.conf # change $projectroot to /home/gitolite/repositories # change $projects_list to /home/gitolite/projects.list
Now you should be able to see the testing repository in gitweb at:
git-daemon setup
sudo apt-get install git-daemon-run
Now we need to change the sv config for git-daemon so that it runs as the gitdaemon user and gitolite group (since gitolite group has read access to the repositories)
sudo emacs /etc/sv/git-daemon/run
Change:
#!/bin/sh exec 2>&1 echo 'git-daemon starting.' exec chpst -ugitdaemon \ "$(git --exec-path)"/git-daemon --verbose --base-path=/var/cache /var/cache/git
to:
IMPORTANT: notice the change from -ugitdaemon
to -ugitdaemon:gitolite
#!/bin/sh exec 2>&1 echo 'git-daemon starting.' exec chpst -ugitdaemon:gitolite \ "$(git --exec-path)"/git-daemon --verbose --base-path=/home/gitolite/repositories /home/gitolite/repositories
Restart git-daemon:
sudo sv restart git-daemon
You should now be able to clone the testing
repo via the git protocol:
git clone git://git.server/testing.git