Git多种部署方式

释放双眼,带上耳机,听听看~!

二进制安装

使用yum来安装二进制git,可以看到我们updates源内的git版本为1.8.3.1

sudo yum info git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : git
Arch        : x86_64
Version     : 1.8.3.1
Release     : 20.el7
Size        : 4.4 M
Repo        : updates/7/x86_64
Summary     : Fast Version Control System
URL         : http://git-scm.com/
License     : GPLv2
Description : 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.

sudo yum install git -y

源码安装

两个途径下载git源码,分别是linux内核官网和github
内核下载地址:https://mirrors.edge.kernel.org/pub/software/scm/git/
github下载地址:https://github.com/git/git/releases
如果从源码进行git安装,那么将依赖这些库文件:curl、zlib、openssl、expat,还有libiconv
如果想要git能够支持更多种的文件格式,例如(doc、html、info)那么还需要安装这些库
别忘了安装gcc编译器哦

sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y
sudo yum install asciidoc xmlto docbook2X
sudo yum install gcc-c++ -y
sudo wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.0.0.tar.gz
sudo tar xf git-2.0.0.tar.gz
cd git-2.20.0/

编译检查:
make configure                  以下编译检查失败,我系统是centos7最小化安装,缺少了autoconf库
    GEN configure
/bin/sh: autoconf: 未找到命令
make: *** [configure] 错误 127
sudo yum install autoconf
sudo make configure             以下内容为编译检查成功
    GEN configure
sudo ./configure --prefix=/usr/local/git

编译安装
sudo make all doc info
/bin/sh:行1: docbook2x-texi: 未找到命令                       这里编译它告诉你没有找到docbook2x-texi,注意上面我们用yum装的1是dockbook2x,不是docbook2x-texi
make[1]: *** [user-manual.texi] 错误 127
make[1]: 离开目录“/opt/git-2.0.0/Documentation”
make: *** [info] 错误 2
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/d/docbook2X-0.8.8-17.el7.x86_64.rpm  安装docbook2x-texi库文件
sudo ln -s  /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi      docbook2x-texi库文件装好之后默认名称为db2x_docbook2texi,需修改为git可识别到的库名称
sudo make all doc info      再次编译
sudo make install install-doc install-html install-info     安装,顺便安装能够支持doc、html、info的文件格式给安装上
echo $?
0
sudo ln -s /usr/local/git/bin/git /usr/local/bin/git
git --version
git version 2.0.0

如果使用git命令不可以使用,请添加环境变量
sudo vim /etc/profile
export PATH=$PATH:/usr/local/git/bin/
tail -1  /etc/profile
export PATH=$PATH:/usr/local/git/bin/
source /etc/profile
git --version

安装完成后,如果想更新版本,可以使用下面命令

sudo git clone git://git.kernel.org/pub/scm/git/git.git

windows安装

下载地址:https://git-scm.com/downloads

选择适合你系统的架构

人已赞赏
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧