Tuesday, April 3, 2012

GIT Source Code Management and Version control




=============================
Gitolite Introduction by Yogesh Panchal
=============================

Introduction
------------------

**What is Git ?**

Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.

`More Info Here <http://git-scm.com/>`_


**What is Gitolite ?**

Gitolite allows you to setup git hosting on a central server, with fine-grained access control and many more powerful features.

Gitolite is an access control layer on top of git. Here's an "executive summary":

* use a single unix user ("real" user) on the server

* provide access to many gitolite users

* they are not "real" users

* they do not get shell access

* control access to many git repositories

* read access controlled at the repo level

* write access controlled at the branch/tag/file/directory level, including who can rewind, create, and delete branches/tags

* can be installed without root access, assuming git and perl are already installed

* authentication is most commonly done using sshd, but you can also use httpd if you prefer (this may require root access)

`More Info Here <http://sitaramc.github.com/gitolite/>`_



======================
Gitolite Installation
======================

Prerequisites
--------------

* Perl 5.8.8
* git (yum install git or sudo apt-get install git)

Installation Steps
-------------------

# First Login as root & Add user called "git"

``$ useradd git``

``$ passwd git``



# Now Login as root to any local system & Add user called "gitadmin"

``$ useradd gitadmin``

``$ passwd gitadmin``



# Switch to User gitadmin & generate ssh key as shown

``$ su gitadmin``

``$ ssh-keygen``



# Copy ssh public key as gitadmin.pub

``$ cp .ssh/id_rsa.pub gitadmin.pub``



# Now Copy this ssh key on git server

``$ scp gitadmin.pub git@gitserver:``



# Now Login to git server as user "git" & download gitolite source

``$ git clone http://github.com/sitaramc/gitolite.git``



# Change directory gitolite & run "gl-system-install" command

``$ cd gitolite/``

``$ src/gl-system-install``



# Now run "gl-setup" command

``$ source ~/.bash_profile``

``$ gl-setup gitadmin.pub``

# once you run "gl-setup gitadmin.pub" command hit enter & then the Vi editor pops up, exit it by typing ":wq" (colon,  then the letter 'w' & 'q'), hit enter. Then the installs complete.



#


#


#



# Finally clone the gitolite admin repository

``$ git clone git@gitserver:gitolite-admin.git``



# Add New Repo & New User Key

``$ cd gitolite-admin``

``$ vi conf/gitolite.conf``

# Add Following lines for to add New Repo

`` Repo RepoName``
`` RW+ Username``

# Where Reponame is name of the repo & username is name of user key
# After Adding Repo Generate User Key on user's system

``$ ssh-keygen``

# Copy public key to Gitadmin's system & Add to keydir in gitolite-admin folder

``$ cp .ssh/id_rsa.pub user.pub``

``$ scp user.pub gitadmin@serverip:``

# On Gitadmin's system

``$ cp user.pub gitolite-admin/keydir/``

# Now Commit your changes & push changes on git server

``$ git status``

``$ git add conf/gitolite.conf``

``$ git add keydir/user.pub``

``$ git commit -m "added new Repo & New User"``

``$ git push origin master``

No comments:

Post a Comment