Gitosis and git tutorial.

This is tutorial about gitosis installation and creating git repositories on remote server. So we have remote server and local machine, and we would like to have remote git repository. This tutorial can help you creating personal git repository for your project on linux machine and linux server. Ok lets go...

Server settings.


First step we need to install gitosis on server.
$mkdir ~/src
$git clone git:/eagain.net/gitosis.git
$cd gitosis
$sudo python setup.py install

Second step we need to create user who will manage repositories.
$sudo adduser \

    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
    [username]

Third step generate public ssh-key and initialize git repository
$ssh-keygen -t rsa
Generating public/private rsa key pair.

Enter file in which to save the key (/home/[username]/.ssh/id_rsa):/ssh key path/key name
$sudo -H -u [username] gitosis-init < /ssh key path/key name.pub
$sudo chmod 755 /home/[usesrname]/repositories/gitosis-admin/hooks/post-update


Client settings.


Fourth step clone gitosis settings and add new repository and users in to gitosis.conf
$git clone [username]@youserverhostname:repositories/gitosis-admin.git
$cd gitosis-admin
$vim gitosis.conf

[gitosis]


[group gitosis-admin]
members = bug
writable = gitosis-admin


[group myteam]
members = bug
writable = megaproject


This defines a new group called "myteam", which is an arbitrary string. "bug" is a member of myteam and will have write access to the "megaproject" repo.


Fifth step
s
ave the additions to gitosis.conf, put the ssh public key for user "bug" into keydir
$git commit -a -m "Access granted for user bug"
$git push 


Six step create repository on server
$mkdir ~/repositories/megaproject.git$cd megaproject.git
$git --bare init

Seven step create repository on client
$mkdir megaproject
$cd megaproject
$git init
$git remote add master [username]@youserverhostname:repositories/megaproject.git
$echo "Start megaproject" > Readme
$git add Readme
$git commit -a -m "Start megaproject"

$git push master master

Well, i hope this tutorial makes your git hosting life easier.

No comments:

Post a Comment