GIT on CentOS 6

GIT + gitolite installation
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

GIT installation
cd /usr/src
tar zxvf git-2.2.0.tar.gz
cd git-2.2.0

make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bash.bashrc

source /etc/bashrc
source /etc/bash.bashrc

#export PATH=$PATH:/usr/local/git/bin

git --version

After this is done, you can also get Git via Git itself for updates:
cd /usr/src
git clone git://
cd git

groupadd -g 54001 git
adduser -m --system -g git -d /opt/git -s /bin/bash git

ssh-keygen -t rsa
scp .ssh/ root@

su - git
git clone git://

cd $HOME
mkdir -p bin
gitolite/install -to $HOME/bin

cd $HOME
$HOME/bin/gitolite setup -pk /tmp/

Now go to your workstation and type in
git ls-remote git@server:gitolite-admin

This should return something like 
9dd8aab60bac5e54caf887a87b4f3d35c95b05e4    HEAD
9dd8aab60bac5e54caf887a87b4f3d35c95b05e4    refs/heads/master

GIT Configuration
Prevent git push –force
git config --system receive.denyNonFastForwards true
git config --system receive.denyDeletes true

cat /usr/local/git/etc/gitconfig
       denyNonFastForwards = true
       denyDeletes = true

Administration from workstation
yum install git
mkdir /home/user/work/git
cd /home/user/work/git/
git clone git@srvgit01v:gitolite-admin
cd gitolite-admin/
vim conf/gitolite.conf

git config --global "Git-Admin"
git config --global ""

git add keydir conf
git commit -m 'added users, repos'
git push origin master

Clients access

To check the available repos, and your access to them, use the following:
ssh git@ info
ssh info

Clone down the repo using:
git clone git@
git clone

Mirroring gitolite servers
Gitolite: Add, Edit, or Delete Git Repository Name

Add or create repository
Add entry for new project or repository in your gitolite config (conf/gitolite.conf)
Commit and push your changes. this will create and initialize your new repo.

Rename a repository
Modify the name of repo in your gitolite config (conf/gitolite.conf)
Move or rename the actual directory (depending on where you install it, ex: /home/git/repositories) to match your changes in gitolite config.
Commit and push your changes.

Note: Obviously, this changes the remote url of your repo, so don’t forget to change your git remote url config in your project clones.

Delete a repository:
Open your gitolite config and remove the project from there. commit and push your changes.
Then delete its git directory (ex: /home/git/repositories/projectname.git)
You can also remove users/keys that are no longer used

Generate GIT 2.2 RPM
yum install -y rpm-build


mkdir -p ~/src && cd ~/src
tar -xzvf git-2.2.0.tar.gz
mv git-2.2.0.tar.gz ~/rpmbuild/SOURCES

# Locate .spec file and build rpm
# If you get any errors during build, it is usually because of dependencies. Simply
# install the dependencies with `yum install [dependency]` and run rpmbuild again.

cd ~/src/git-2.2.0 && ls | grep *.spec

rpmbuild -ba git.spec --define '_prefix /usr/local'


%files -n perl-Git -f perl-files

and add
#for CentOS 6
%config(noreplace) /usr/local/git/share/perl5/vendor_perl/*


#for CentOS 5
%config(noreplace) /usr/local/lib/perl5/vendor_perl/5.8.8/*
%config(noreplace) /usr/local/share/man/man3/*

If error: File /usr/src/redhat/SOURCES/git-2.2.0.tar.gz: No such file or directory
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

#for Centos 7

%files -n perl-Git -f perl-files

and add

%config(noreplace) /usr/local/share/perl5/vendor_perl/*

Install GIT 2.2 RPM
#CentOS 5

Installation of RPMforge
rpm --import
rpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm
yum install perl-YAML

rpm --import
yum install perl-YAML-0.72-1.el5.rf.noarch.rpm

yum install git-2.2.0-1.x86_64.rpm git-cvs-2.2.0-1.x86_64.rpm gitk-2.2.0-1.x86_64.rpm perl-Git-2.2.0-1.x86_64.rpm git-email-2.2.0-1.x86_64.rpm git-svn-2.2.0-1.x86_64.rpm git-gui-2.2.0-1.x86_64.rpm gitweb-2.2.0-1.x86_64.rpm --nogpgcheck

#CentOS 6

yum install git-2.2.0-1.el6.x86_64.rpm gitk-2.2.0-1.el6.x86_64.rpm git-cvs-2.2.0-1.el6.x86_64.rpm git-svn-2.2.0-1.el6.x86_64.rpm git-email-2.2.0-1.el6.x86_64.rpm gitweb-2.2.0-1.el6.x86_64.rpm git-gui-2.2.0-1.el6.x86_64.rpm perl-Git-2.2.0-1.el6.x86_64.rpm

#CentOS 7

yum install git-2.2.0-1.el7.centos.x86_64.rpm git-svn-2.2.0-1.el7.centos.x86_64.rpm git-cvs-2.2.0-1.el7.centos.x86_64.rpm git-email-2.2.0-1.el7.centos.x86_64.rpm git-gui-2.2.0-1.el7.centos.x86_64.rpm gitk-2.2.0-1.el7.centos.x86_64.rpm gitweb-2.2.0-1.el7.centos.x86_64.rpm perl-Git-2.2.0-1.el7.centos.x86_64.rpm git-debuginfo-2.2.0-1.el7.centos.x86_64.rpm

Delete Git branch
ssh root@srvgit01v
cd /opt/git/repositories/repo1.git

git branch -D

chown -R git:git /opt/git/repositories/repo1.git


Leave a comment

You must be logged in to post a comment.