Rackspace maintains the ius repository, which contains a reasonably up-to-date git, but the stock git has to first be removed.
CentOS 6 or 7 instructions (run as root or with sudo):
# retrieve and check CENTOS_MAIN_VERSION (6 or 7):
CENTOS_MAIN_VERSION=$(cat /etc/centos-release | awk -F 'release[ ]*' '{print $2}' | awk -F '.' '{print $1}')
echo $CENTOS_MAIN_VERSION
# output should be "6" or "7"
# Install IUS Repo and Epel-Release:
yum install -y https://repo.ius.io/ius-release-el${CENTOS_MAIN_VERSION}.rpm
yum install -y epel-release
# re-install git:
yum erase -y git*
yum install -y git-core
# check version:
git --version
# output: git version 2.24.3
Note: git-all
instead of git-core
often installs an old version. Try e.g. git224-all
instead.
The script is tested on a CentOS 7 docker image (7e6257c9f8d8
) and on a CentOS 6 docker image (d0957ffdf8a2
).