Installing Git on a New Server
Installing Git on a New Server
Join the DZone community and get the full member experience.Join For Free
Easily enforce open source policies in real time and reduce MTTRs from six weeks to six seconds with the Sonatype Nexus Platform. See for yourself - Free Vulnerability Scanner.
I’ve been hearing a lot of good about Git in the last few years, from the simplicity of use, speed to decentralized repositories. I’ve been a happy user of SVN for many years, and I know that it’s got it’s problems, but I suspect so does Git. The time has come to experience them though.
Here’s a quick run through, how to install Git on a new server.
Depending on your environment run for simple and quick install:
$ sudo yum install git-core $ sudo apt-get install git-core
Unlike, like me, you get a dependency issue while trying to install your packages :
Error: Package: git-1.7.1-2.el6_0.1.i686 (base) Requires: perl-Git = 1.7.1-2.el6_0.1 Error: Package: logwatch-7.3.6-49.el6.noarch (base) Requires: perl(Date::Manip) Error: Package: git-1.7.1-2.el6_0.1.i686 (base) Requires: perl(Git) Error: Package: git-1.7.1-2.el6_0.1.i686 (base) Requires: perl(Error)
There is a solution though. This might be because your system prevents yum from updating certain packages. Edit your yum.conf, and check your exclude list.
$ vim /etc/yum.conf
Remove perl*| from that list and try to install git-core again.
Now, let’s check if the git was installed correctly:
$ git --version git version 1.7.1
Installing Gitolite for multi-user repositories
Those files are not going to version themselves.
Gitolite is one of the most popular solutions for multi-user Git. It is the solution recommended by the official git Reference Manual.
First, we need to create a git user
$ sudo adduser git $ su git`
And git clone the latest version of gitolite:
$ git clone git://github.com/sitaramc/gitolite
If your server is behind a firewall you might get the error below:
Initialized empty Git repository in /home/git/gitolite/.git/ github.com[0: 184.108.40.206]: errno=Connection timed out fatal: unable to connect a socket (Connection timed out)
Make sure that you allow connections to and from port 9418 which is the port on which git operates.
Now create a .pub file from your workstation in $HOME directory of the git user, and run the commands below
$ mkdir -p $HOME/bin $ gitolite/install -to $HOME/bin $ $HOME/bin/gitolite setup -pk Workstation_Name.pub
Gitolite uses gitolite-admin repository to store the information on users, repos and access. All of the changes to the configuration should be made in that repository, and never on the server.
In order to administer your git repository run the command below on your workstation, you should be able to access it without the password, thanks to the public key you set up previously.
$ git clone git@host:gitolite-admin $ cd gitolite-admin $ ls
You should be able to see two directories.
keydir is the storage for all the public keys for new users, i.e. john.pub will let john access your repository.
conf/gitolite.conf stores information on all your repositories i.e.
repo foo RW+ = john
- a permission of RW matches only a fast-forward push or create
- a permission of RW+ matches any type of push
- a permission of ‘-’ matches any type of push
You can read more about Access Rules if you have a look at the Gitolite documentation.
Published at DZone with permission of Kasia Gogolek , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.