May 19th, 2008
So you wanna host your own git repos? Got Leopard? Got Git? Read On...
Assumptions: You have git installed.
Create a git server on leopard with gitosis
Download and install gitosis
mkdir src git clone git://eagain.net/gitosis.git cd gitosis sudo python setup.py install
Create a git user and group on the server
Create a unix user and group for git, using dscl: leopard's directory service cli
1. Find an unused uid and gid
sudo dscl . list /Users uid sudo dscl . list groups gid
(check that, say, 401, is unused in both)
2. Create the git group
sudo dscl . create groups/git sudo dscl . create groups/git gid 401
3. Create the git user
sudo dscl . create users/git sudo dscl . create users/git uid 401 sudo dscl . create users/git NFSHomeDirectory /Users/git sudo dscl . create users/git gid 401 sudo dscl . create users/git UserShell /bin/bash sudo dscl . create users/git Password '*'
4. Create the git home directory (make this location match the end of line 3 above)
sudo mkdir /Users/git sudo chown git /Users/git sudo chgrp git /Users/git
Create an ssh key, and copy it to the server
1. If you don't already have one, create an ssh key, on your local machine if it is not the server
ssh-keygen -t rsa
2. Copy the public key to /tmp on the server
(if your local machine is the server)
cp ~/.ssh/id_rsa.pub /tmp/my_key.pub
(if the server is different from your local machine)
scp ~/.ssh/id_rsa.pub your.server.com:/tmp/my_key.pub
Setup gitosis in git user's home directory
1. Initialise gitosis [on the git server]
sudo -H -u git gitosis-init < /tmp/my_key.pub(you should see something like this:)
Initialized empty Git repository in ./ Reinitialized existing Git repository in ./
2. Make sure git's paths are set to your current ones (where you can see gitosis and git)
sudo su git (enter your password) echo "export PATH=$PATH" > ~/.bashrc exit
Update: drwestco advises that with git 1.6 you should append the following line to the git user's .bash_rc.
export PATH=$(git --exec-path):$PATH
Clone the gitosis repo to your local machine
git clone email@example.com:gitosis-admin.git
If you see something like this, then you're all set
remote: Counting objects: 5, done. remote: Compressing objects: 100% (4/4), done. remote: Total 5 (delta 0), reused 5 (delta 0) Receiving objects: 100% (5/5), done.
Troubles? Make sure that you can ssh to the server as git (make sure that Leopard's ssh settings allow any user to login, or edit /etc/sshd_config). Otherwise post your troubles here in the comments.