In this blog I will going to provide the step to setup your own git server on Ubuntu.
For doing the same we have to install the couple of package.
- Setup Git
- Create new user
- Generate SSh Key
- Copy your public key to git user account
- Setup Gitolite
- Take control
Using following command we can install Git
sudo apt-get install git-core
We can create a new user using
root@localhost:~# sudo adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/git git
Here we have disabled the password because we will access using ssh key.
We can generate ssh key using
ssh-keygen -t rsa -f gitolite
or we can use old one.
Now we have to copy the public key name git.pub to git user using
sudo cp ~/.ssh/git.pub /home/git/
and change the owner of git.pub using
sudo chown git:git /home/git/git.pub
Now we have to setup the Gitolite in git user. We have to login in system using git user using
sudo su - git
Now we have to install to Gitolite using
git clone git://github.com/sitaramc/gitolite
We will install it in the git user’s home directory under “~/bin”, so we first create this directory using
mkdir bin
Now change dir to cloned gitolite and install it using
gitolite/install -to /home/git/bin
Now we will upload git.pub to gitolite so the user how have this public key can commit and push the changes. We will do it using
/home/git/bin/gitolite setup -pk git.pub
We are done with installation. Exit from git using using
exit
Here Git controlling git. Let’s download the gitolite-admin from our newly created git repository using
git clone git:gitolite-admin
Change dir to gitolite-admin and execute the ls command and you will find there 2 directory named conf and keydir.
Now we are ready to manage the git server manually or programmatic .
Open the gitolite.conf file and start creating user. You can see the config in file like
repo gitolite-admin RW+ = local repo testing RW+ = @all repo jellyfishgitrepo RW+ = jellyfish
Here I have create a new repo named “jellyfishgitrepo” and provide the read and write access and jellyfish is the name of public key. you have to create a public key name jellyfish.pub and put it in keydir and push it to server. Once we have pushed it successfully to gitolite it will create a new repository and provide access to user who have jellyfish.pub.
I hope that gives you a good overview of how to install gitolite.
Recent Comments