This is a quick note on how to create a multi-user git server hosted on your own FreeBSD set-up, using the SSH protocol for reading/writing from/to repositories. Steps to follow (as ‘root‘):
- Install the ‘git‘ package:
pkg_add -r git
- Create a group called ‘gitusers‘:
pw groupadd gitusers
- Create a user called ‘gitserver‘, part of the ‘gitusers‘ group, without shell access:
pw useradd gitserver -g gitusers -s /sbin/nologin -m
- Invite existing users to the ‘gitusers‘ group, (e.g.: users ‘tom‘ and ‘alice‘):
pw usermod tom -G gitusers pw usermod alice -G gitusers
- Create a new example repository, in `/home/gitserver/‘, called ‘example-repository‘:
# Create an empty repository: cd /home/gitserver/ mkdir example-repository cd example-repository git init # Clone into a bare repository: cd .. git clone --bare example-repository example-repository.git
- Change permissions, to allow ‘gitusers‘ group members to execute and read/write from/to repository contents:
cd /home/gitserver/ chown -R gitserver:gitusers ./example-repository.git/ chmod -R g=rxw ./example-repository.git
- Clone the repository on the client machine, and add your first commit to the ‘master‘ branch: NOTE: Replace hostname.tld, with the hostname of your machine.
# Clone the repository: git clone ssh://tom@hostname.tld/home/gitserver/example-repository.git # Add your first commit: cd example-repository.git touch README git add README git commit -am "First commit." # Push changes git push origin master
References:
http://git-scm.com/book/ch4-2.html
http://www.freebsd.org/doc/handbook/users.html