Wednesday, December 25, 2019

git - building from source on CentOS 6

I wanted to revise my knowledge and skills in git.

Taking a GitHub course sounded like a good idea, but git is invasive into user/credentials/config matters so I didn't dare to do it from my main user.

Old CentOS 6 machine collects dust under my desk and no one cares about it. Why cannot I make my git lessons on it?

$ git --version
$ git version 1.7. ..
(cannot recall the last digit)

Upgrade does not help - the official RHEL repository only has outdated version.
Should I add another repository and try upgrading from there?.. Or perhaps just try building from source?

Let's get source:

$ mkdir gitsource
$ cd gitsource
$ git clone https://github.com/git/git

Now I have the source in gitsource/git. Googling for build instructions leads me here and I do exactly as it reads:

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
$ yum install gcc perl-ExtUtils-MakeMaker

This provides me with old as my life gcc version 4.4.7 and all rusty rest.

Let's start building:

$ cd git $ make prefix=/usr/local/git all

It runs... Uuups! git-http-fetch error 1

Googling the error. Answers look unrelated.

Looking up the terminal. Compiler goes to anaconda directory at different user. What is in the PATH? Exactly! The path to anaconda goes first. Remove it.

No more errors.

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

It's not the best idea to change global PATH, just have stumbled at it, but at least adding it at the end.

Checking:

$ git --version
$ git version 2.24.GIT

Now I can start learning.