Bare Git repository with Gitosis

Page content

Install gitosis

On Ubuntu20 Python 2!!

https://github.com/tv42/gitosis/blob/master/README.rst https://www.howtoforge.com/setting-up-gitosis-on-ubuntu

apt install -y python-setuptools
git clone https://github.com/tv42/gitosis.git
cd gitosis
sudo python2 setup.py install

sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /srv/example.com/git \
    git

ssh-keygen -b 4096
sudo -H -u git gitosis-init < .ssh/id_rsa.pub
sudo chmod 755 /srv/example.com/git/repositories/gitosis-admin.git//hooks/post-update

client side

git clone git@serverdomain:gitosis-admin.git

Create user

Put pubkey to gitosis-admin/keydir

vim keydir/foo.pub

edit gitosis.conf. add the foo user.

[group gitosis-admin]
members = youruser@serverdomain.com foo
writable = gitosis-admin

caution: keyname foo.pub and user foo same.

Then, foo user can clone gitosis-admin

config .ssh/config

Host serverdomain.com
    user git
    identityFile ~/.ssh/id_foo

git clone serverdomain.com:gitosis-admin.git

  • The user should git! but the key is added.
  • No user but KEY!!

Configure your repo

https://ssteiner.wordpress.com/2009/05/13/adding-a-new-repository-under-gitosis-2/

  1. edit gitosis.conf. add the lines.
[group exampleproject]
members = foo
writable = myproject
  1. commit and push git commit -a -m "Added new group 'exampleproject' and project 'myproject'" git add gitosis.conf gitosis-admin$ git commit -m “add new group” git push
  2. In local, crate a new repo.
mkdir myproject
cd myproject
git init
echo "sample file!!" > sample.txt
git add sample.txt
git commit -a -m "First commit"
git remote add origin foo@yourserver.com:myproject.git
git push origin master

Memo: Add a permission as group

[group testgroup]
writable = testproject
members = @groupname