Centos – Installing git “sudo: apt-get: command not found”

aptcentoscommand linegityum

I am trying to install git. I run the following command:

sudo apt-get install git-core git-gui git-doc

But receive the following error:
sudo: apt-get: command not found

What should I do?

Best Answer

Since you're using CentOS 5, the default package manager is yum, not apt-get. To install a program using it, you'd normally use the following command:

$ sudo yum install <packagename>

However, when trying to install git this way, you'll encounter the following error on CentOS 5:

$ sudo yum install git
Setting up Install Process
Parsing package install arguments
No package git available.
Nothing to do

This tells you that the package repositories that yum knows about don't contain the required rpms (RPM Package Manager files) to install git. This is presumably because CentOS 5 is based on RHEL 5, which was released in 2007, before git was considered a mature version control system. To get around this problem, we need to add additional repositories to the list that yum uses (We're going to add the RPMforge repository, as per these instructions).

This assumes you want the i386 packages. Test by running uname -i. If you want the x86_64 packages, replace all occurrences of i386 with x86_64 in the following commands

First, download the rpmforge-release package:

$ wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm

Next, verify and install the package:

$ sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
$ rpm -K rpmforge-release-0.5.3-1.el5.rf.i386.rpm
$ sudo rpm -i rpmforge-release-0.5.3-1.el5.rf.i386.rpm

And now we should be able to install git:

$ sudo yum install git-gui

yum will work out the dependencies, and ask you at relevant points if you want to proceed. Press y for Yes, and n or return for No.

Related Question