Professional Documents
Culture Documents
What Is Git ?
It is a very popular and efficient open source Version Control System. It tracks content such
as files and directories.
It stores the file content in BLOBs (binary large objects). The folders are represented as trees.
More Info..BLOBS- http://www.techterms.com/definition/blob
How to install own git server with ssh and http access by using gitolite and gitweb in Linux.
For user management in Git Server.
I'm Creating a private git server. And can be accesible through ssh and http both.Here Gitweb
will be used for viewing repositories detail. Gitolite is used for Git server with user/group
management.
What Is Gitolite ?
It is an access control layer on top of git.
Step-1 Login Your Git Server PC and configure or change hostname & entry in FQDN..
(server.ashu.com)
1- Change Ip Address
---------------------------------------------------------------
DEVICE="eth0"
IPADDR=192.168.1.5
NETMASK=255.255.255.0
HWADDR="00:16:D4:39:5B:6F"
NM_CONTROLLED="yes"
ONBOOT="yes"
----------------------------------------------------------------
2- Change Hostname
HOSTNAME=server.ashu.com
4- Check Hostname..
5- Check IP..
Login into your linux pc from where you want to manage git server remotely .
Means here I am talking about your client system..
2- Copy the pub key (id_rsa.pub) to the */tmp* directory on our Git Server.
3- Move the pub key of Git-Admin user that we have created above from */tmp* and set
the appropriate permission.
4- Login with user git directly from terminal.Do not set password for user git. And git
clone the
gitolite from github.com
9- Create a directory bin under /var/www (Web Server Root) as per *suexec* output
and set the appropriate permission.
10- Now create gitolite-suexec-wrapper.sh (bash script) with following content under
/var/www/bin.
----------------------------------------------------------------------------------
#!/bin/bash
#
# Suexec wrapper for gitolite-shell
#
export GIT_PROJECT_ROOT="/home/git/repositories"
export GITOLITE_HTTP_HOME="/home/git"
exec ${GITOLITE_HTTP_HOME}/gitolite/src/gitolite-shell
----------------------------------------------------------------------------------
2- Rename the git directory (under /var/www/git) to *gitweb* and change the ownership
to git.
4- Now create a dummy folder git and set the appropriate permission.
------------------------------------------------------------------------------
# You can comment out the below 3 lines and put correct value as per your
server information
ServerName server.ashu.com
ServerAlias server
ServerAdmin root@ashu.com
DocumentRoot /var/www/git
Options None
AllowOverride none
Order allow,deny
Allow from all
AuthType Basic
AuthName "Git Access"
Require valid-user
AuthUserFile /etc/httpd/conf/git.passwd
------------------------------------------------------------------------------
Alias /gitweb /var/www/html/gitweb
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
AuthType Basic
AuthName "Git Access"
Require valid-user
AuthUserFile /etc/httpd/conf/git.passwd
------------------------------------------------------------------------------
7- We will create Apache Basic auth username and password using *htpasswd*.
8- Restart the Apache Web service and enable it to autostart in runlevel (3 & 5) during
system startup.
10- Verify the GitWeb is running fine using your favorite browser.
http://(ip-address OR FQDN) of git-server/gitweb/
http://192.168.1.5
http://server.ashu.com
Step-5 Go To Clien PC and Verify that you are able to clone the git using http from
Client Machine.
$ mkdir ~/git-repo/
$ cd ~/git-repo
$ git clone git@192.168.1.5:testing.git
Note- 192.168.1.5 ip is a Server IP Address..
Step-6 Manage user and group of Git Server (from remote client Machine).
1- To manage Git user and groups on Git-Server, we need to clone the gitolite-admin
repo.
$ cd ~/git-repo
$ git config --global user.name "Git-Admin"
$ git config --global user.email "root@ashu.com"
$ git clone git@192.168.1.5:gitolite-admin.git
First, obtain pubkeys for your users. We will start with the example users user-1 and user-2.
Ask both of them to generate a keypair just as we did in upper most section of this doc., and
send you their keys somehow.
Save them with their respective names (user-1.pub and user-2.pub) in /tmp of your
workstation.
Now you have your two users, let us assume that your two new repos are dev and prod. The
dev repo must be
writeable by user-1, but read-only to user-2. The prod repo is the other way around writeable
by user-2, read-only to user-1.
Now, on on your client machine under gitolite-admin/keydir copy the pub keys of user-1 and
user-2:
$ cd ~/git-repo/gitolite-admin
$ cp /tmp/user-1.pub /tmp/user-2.pub keydir
$ vim conf/gitolite.conf
----------------------------------
repo gitolite-admin
RW+ = sena
repo testing
RW+ = @all
repo dev
RW = user-1
R = user-2
repo prod
RW = user-2
R = user-1
:wq! (Save & Quit)
----------------------------------
$ git commit -m 'added users user-1 and user-2, repos dev and prod'
[master 4932ca2] added users user-1 and user-2, repos dev and prod
3 files changed, 10 insertions(+), 0 deletions(-)
create mode 100644 keydir/user-1.pub
create mode 100644 keydir/user-2.pub
$ cd repositories
$ mkdir test-repo.git
$ cd test-repo.git
$ git --bare init
$ git update-server-info
$ rm file1
$ git commit -m "Removing file file1"
$ git push origin master
4- Sync the file to local File System from Git Server if someone deleted file locally.
Ashutosh
1 Share
3