The version of git that comes with RHEL6 is very old. I'll outline steps for compiling the latest git version on RHEL6. Working from /usr/local/src
.
Following instructions for Git Pro book Getting Started Installing Git.
yum install gcc curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker
Optional man page prereqs.
yum install asciidoc xmlto
If using Debian derivative...
apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto
cd /usr/local/src
git clone https://github.com/git/git.git
cd git
#old method
#git ls-remote origin | grep tags
#git checkout v1.8.4
#checkout latest stable version
git checkout $(git ls-remote --tags origin | grep -o 'refs/tags/[^^]\+' | sort -Vr | head -n1)
export DEFAULT_HELP_FORMAT="man"
autoconf
./configure
make && make install
Optionally install man pages (recommended).
make man && make install-man
Edit /etc/profile
export PATH="/usr/local/bin:${PATH}"
cd /usr/local/src/git/
git reset --hard
git clean -xfd
git ls-remote | grep tags
git fetch
#checkout latest stable version
git checkout $(git ls-remote --tags origin | grep -o 'refs/tags/[^^]\+' | sort -Vr | head -n1)
autoconf && ./configure && make && make install && make man && make install-man
Oneliner to install the latest stable git version from git source. Assumes building and installing man pages as well.
cd /usr/local/src/git/ && git reset --hard && git clean -xfd && git fetch && git checkout $(git ls-remote --tags origin | grep -oE 'v[0-9]+(.[0-9]+){2}$' | tail -n1) && autoconf && ./configure && make && make install && make man && make install-man
Your original formulation of
grep
under "Checkout and compile" works better IMO and without the need forcut
. Also, that sub-shell returnsv2.9.5
as the latest release.Consider using a
sort -V
in the pipe just before thetail
so the correct version is returned (at the time of this writing,v2.19.0
)Like so:
git clone -b $(git ls-remote https://github.com/git/git.git | grep -oE 'v[0-9]+(.[0-9]+){2}$' | sort -V | tail -n1) https://github.com/git/git.git
@douglasnaphas this sort deficiency would affect your docker image too if you haven't already corrected it.