Git之Linux安装

Git是一个开源的分布式版本控制系统,可以有效、高速的处理从很小到非常大的项目版本管理,是目前使用范围最广的版本管理工具。
当前我所使用的Linux式rhel7.4. 其他版本也是差不多的。在系统的镜像中默认有git这个工具包的。那些下面我们来看一下怎么做操作把。

  • 利用yum从仓库安装
  • 我们可以先用命令查看git这个软件包的信息
[root@localhost ~]# yum info git
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
可安装的软件包
名称    :git
架构    :x86_64
版本    :1.8.3.1
发布    :11.el7
大小    :4.4 M
源      :rhel
简介    : Fast Version Control System
网址    :http://git-scm.com/
协议    : GPLv2
描述    : Git is a fast, scalable, distributed revision control system with an
        : unusually rich command set that provides both high-level operations
        : and full access to internals.
        : 
        : The git rpm installs the core tools with minimal dependencies.  To
        : install all git packages, including tools for integrating with other
        : SCMs, install the git-all meta-package.
  • 然后我们可以进行安装
[root@localhost ~]# yum -y install git			#-y 选项是同意安装
.........
[root@localhost ~]# rpm -q git		#查看git是否安装成功。
git-1.8.3.1-11.el7.x86_64
[root@localhost ~]# git --version		#我们也可以通过  --version 查看git的版本
git version 1.8.3.1
#Git默认安装在/usr/libexec/git-core目录下
[root@localhost ~]# ls /usr/libexec/git-core/ | grep git	#可以通过这样的方式查看
git
git-add
........
  • 如果觉得版本底的话,我们可以从github的Git版本发布界面下载新的版本。
  • Git版本发布界面
    在这里插入图片描述
    确保你的虚拟可以上网,或者可以先下载,然后传输到你的Linux上。
  • 源码编译安装Git
#在能上网的情况下,使用wget命令下载
[root@room13pc37 ~]# wget https://github.com/git/git/archive/v2.21.0.tar.gz
[root@room13pc37 ~]# ls
 v2.21.0.tar.gz       		#下载到当前目录下,会出现这个文件      
[root@localhost ~]# tar -zxvf v2.21.0.tar.gz 		#使用tar命令解压缩。显示解压缩内容
[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker #安装编译源码所需依赖的软件包 

#安装依赖时,yum自动安装了Git,需要卸载旧版本Git,使用remove命令 出现提示输入y即可 
[root@localhost ~]# yum remove git 		#会提示删除成功

#接下来我们需要进入刚才解压后的文件夹,执行执行编译,
[root@localhost git-2.21.0]# make prefix=/usr/local/git all	#时间比较长,需要耐心等待

#安装Git到/usr/local/git路径
[root@localhost git-2.21.0]# make prefix=/usr/local/git install

#打开环境变量配置文件,在底部加上Git相关配置信息
[root@localhost git-2.21.0]# vim /etc/profile
PATH=$PATH:/usr/local/git/bin	#在配置文件的末尾加上这两行内容。
export PATH 

#重启,然后查看安装的git版本,有版本显示,说明校验通过,安装成功
[root@localhost ~]# git --version
git version 2.21.0


更多关于Git的内容,请看下面的链接:

Git官方文档:Git-Book

Git工作流:深入理解学习Git工作流

文章是从环境部署(三):Linux下安装Git 整理,
写得不好,大家见谅~

猜你喜欢

转载自blog.csdn.net/REVE_HOH/article/details/89225047
今日推荐