Over a million developers have joined DZone.

Installing Git on a New Server

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

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.

Installing Git

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

Awesome!

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: 207.97.227.239]: 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 

Configuration

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

Where:

  • 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.




The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

Topics:

Published at DZone with permission of Kasia Gogolek, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}