Git学习01:Git安装

Linux Centos7 安装

一、yum安装,只要执行 yum -y  install git 即可,但是yum安装无法控制版本,可能版本会比较老,推荐使用方法二

 

[root@ecs-x-large-2-linux-20200229160057 ~]# yum -y  install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
......

Installed:
  git.x86_64 0:1.8.3.1-21.el7_7                                                                                                                                                                                  

Dependency Installed:
  perl-Error.noarch 1:0.17020-2.el7                  perl-Git.noarch 0:1.8.3.1-21.el7_7                  perl-TermReadKey.x86_64 0:2.30-20.el7                  rsync.x86_64 0:3.1.2-6.el7_6.1                 

Complete!
[root@ecs-x-large-2-linux-20200229160057 ~]# git --version
git version 1.8.3.1

 

二、从GitHub上下载最新的源码编译后安装

1- 去Gitbub下载安装包XXX.tar.gz文件,并上传到Linux服务器/usr目录下

 

 

2-  解压压缩包,并进入到解压后的文件夹

[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# cd /usr
[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# tar -zxvf git-2.26.0.tar.gz 
......
[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# cd git-2.26.0
/usr/git-2.26.0

3-  安装编译所需要的依赖(安装依赖是会自动使用yum下载git,这里需要手动删除)

[root@ecs-x-large-2-linux-20200229160057 ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

[root@ecs-x-large-2-linux-20200229160057 ~]# git --version
git version 1.8.3.1

[root@ecs-x-large-2-linux-20200229160057 ~]# yum -y remove git
[root@ecs-x-large-2-linux-20200229160057 ~]# git --version
-bash: /usr/bin/git: No such file or directory

4-编译git源码,并安装git至/usr/local/git路径

[root@ecs-x-large-2-linux-20200229160057 ~]# cd /usr/git-2.26.0
[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# make prefix=/usr/local/git all
......
[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# make prefix=/usr/local/git install
......

 

 5-配置环境变量,并刷新

[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# vi /etc/profile
##在文件尾部追加 export PATH=$PATH:/usr/local/git/bin

#刷新环境变量
[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# source /etc/profile

 

 6-查看Git是否安装完成

[root@ecs-x-large-2-linux-20200229160057 git-2.26.0]# git --version
git version 2.26.0

 

END

posted on 2020-04-10 19:28  我不吃番茄  阅读(230)  评论(0编辑  收藏  举报