Git的安装

本日记记录都是经常用到但是记不住,总是来回到网络上搜集的内容。日记中的有些内容是复制粘贴来的,如果认为是侵权,请联系我。

1. Windows

到官网下载安装程序进行安装。不建议到其他的下载网站下载,避免安装了你并想要但又不好清理的东西。

Git官方下载网址  https://git-scm.com/downloads

2. CentOs 

CentOs有三种安装Git的方法,各有利弊。

2.1 默认安装

yum install git

通过这样的方法安装的Git版本较低,应该是1.7

2.2 源程序安装

1.安装依赖

Git 的工作需要调用 curl,zlib,openssl,expat,libiconv 等库的代码,所以需要先安装这些依赖工具

方法1:

1-1.

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

1-1(2)

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc

yum install gcc perl-ExtUtils-MakeMaker

方法2:

yum install curl-devel expat-devel gettext-devel \ openssl-devel zlib-devel

2.删除当前版本

yum remove git

3-1.跳转到指定的安装目录

cd /usr/src

3-2.下载 git 安装包

wget https://www.kernel.org/pub/software/scm/git/git-2.8.3.tar.gz --no-check-certificate

3-3.解压 git 安装包

tar -zxvf git-2.8.3.tar.gz

3-4.跳转解压文件

cd git-2.8.3

3-5.配置安装路径

./configure prefix=/usr/local/git/

3-6.编译并安装

make && make install

3-7.编辑环境变量

vi /etc/profile

最后添加一行

export PATH=$PATH:/usr/local/git/bin

另一个方法

echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile

3-8.启动这个配置文件

source /etc/profile

4.查看版本号

git --version

2.3  通过IUS安装 

安装IUS的资源包:参照官网 https://ius.io/setup

Setup

To enable the IUS repository on your system, install the ius-release package. This package contains the IUS repository configuration and public package signing keys. Many IUS packages have dependencies from the EPEL repository, so install the epel-release package as well.

RHEL/CentOS 6

yum install \

https://repo.ius.io/ius-release-el6.rpm \

https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

RHEL/CentOS 7

yum install \

https://repo.ius.io/ius-release-el7.rpm \

https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Testing

IUS packages are first made available in the ius-testing repository before being promoted to the main repository. When you install ius-release, the ius-testing repository is disabled by default. Enable it if you would like to participate in testing new IUS packages.

yum install yum-utils

yum-config-manager --enable ius-testing

.输入yum repolist命令,查看ius/x86_64是否安装成功

输入yum provides git,查看提供的Git版本

安装提供中的版本 yum install git222

查看安装后的最新版本git --version

你可能感兴趣的:(Git的安装)