摘要:基于linux(centos6.9)的git源码编译安装。
问题提出
[hadoop@hadoop01 ~]$ git clone https://github.com/mobz/elasticsearch-head.git
-bash: git: command not found
公共工具
[hadoop@hadoop01 ~]$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
下载
[hadoop@hadoop01 ~]$ wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz
解压
[hadoop@hadoop01 ~]$ xz -d git-latest.tar.xz
[hadoop@hadoop01 ~]$ tar -xvf git-latest.tar
编译安装
[hadoop@hadoop01 git-2017-09-19]$ cd git-2017-09-19/
[hadoop@hadoop01 git-2017-09-19]$ autoconf
[hadoop@hadoop01 git-2017-09-19]$ ./configure --prefix=/usr/local/git
[hadoop@hadoop01 git-2017-09-19]$ make
[hadoop@hadoop01 git-2017-09-19]$sudo make install
配置系统环境
[root@hadoop01 bin]# vim /etc/profile
export GIT_HOME=/usr/local/git
export PATH=${GIT_HOME}/bin:${PATH}
[root@hadoop01 bin]# source /etc/profile
测试
[root@hadoop01 ~]# git --version
git version 2.14.GIT
完成
[root@hadoop01 ~]# git https://github.com/mobz/elasticsearch-head.git
git: 'https://github.com/mobz/elasticsearch-head.git' is not a git command. See 'git --help'.
[root@hadoop01 ~]# git clone https://github.com/mobz/elasticsearch-head.git
Cloning into 'elasticsearch-head'...
remote: Counting objects: 4224, done.
remote: Compressing objects: 100% (96/96), done.
remote: Total 4224 (delta 82), reused 97 (delta 43), pack-reused 4085
Receiving objects: 100% (4224/4224), 2.19 MiB | 139.00 KiB/s, done.
Resolving deltas: 100% (2316/2316), done.
附
不编译安装
[hadoop@hadoop02 ~]$ sudo yum install git
Download for Linux and Unix
It is easiest to install Git on Linux using the preferred package manager of your Linux distribution. If you prefer to build from source, you can find the tarballs on kernel.org.
Debian/Ubuntu
# apt-get install git
Fedora
# yum install git (up to Fedora 21)
# dnf install git (Fedora 22 and later)
Gentoo
# emerge --ask --verbose dev-vcs/git
Arch Linux
# pacman -S git
openSUSE
# zypper install git
Mageia
# urpmi git
FreeBSD
# pkg install git
Solaris 9/10/11 (OpenCSW)
# pkgutil -i git
Solaris 11 Express
# pkg install developer/versioning/git
OpenBSD
# pkg_add git
Alpine
$ apk add git
Red Hat Enterprise Linux, Oracle Linux, CentOS, Scientific Linux, et al.
RHEL and derivatives typically ship older versions of git. You can download a tarball and build from source, or use a 3rd-party repository such as the IUS Community Project to obtain a more recent version of git.
【作者:happyprince; http://blog.csdn.net/ld326/article/details/78034441】