There are multiple ways of installing Git on Linux. Depending on which Linux distribution you're using and whether it provides binary packages for Git, you can either install a binary package or install from source.
The best place to look for exact instructions is your distribution's documentation. Though the instructions here may cover the most popular distributions, your particular distribution may be different.
If your distribution uses the apt tool, this would be the best way to install Git. Often, the Git package is not called git as expected though. It's usually called git-core. So, try the following command: sudo apt-get install git-core.
Similarly, if your distributing uses the yum command to install packages, try the following command: yum install git-core.
If your distribution doesn't have Git binary packages or those packages are out of date, you can install from source. Before you do this, you'll need GCC and all related packages installed. On some systems, installing the package build-essential will do this for you. In addition, you'll need the following libraries and their related development packages installed.
- expat - An XML Parser
- curl - An HTTP library
- zlib - A compression library
- openssl - An encryption library
Once all of these are installed, you can download the Git source from the Git homepage, extract, build and install as any other software from source code.
$ tar xjf git-1.6.x.x.tar.bz2 $ cd git-1.6.x.x $ make prefix=/usr all $ sudo make prefix=/usr install