Linux中通过源码安装Git(SUSE举例)

Linux中离线安装Git,一般都是通过下载离线包进行编译、安装,这样既能保证Git的版本最新,也可以增加更多的文档格式支持。
但是大家主要遇到的问题就是Git依赖包的问题,根本搞不清依赖关系。根据Git官方文档推荐的Git Pro这本书提醒,可以实现Git的离线安装。
这本书有中文版,大家可以在线、下载查看。
Git Pro 第一章第五小节(https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)写道:

Installing from Source

Some people may instead find it useful to install Git from source,
because you’ll get the most recent version. The binary installers tend
to be a bit behind, though as Git has matured in recent years, this
has made less of a difference.

If you do want to install Git from source, you need to have the
following libraries that Git depends on: curl, zlib, openssl, expat,
and libiconv. For example, if you’re on a system that has yum (such as
Fedora) or apt-get (such as a Debian based system), you can use one of
these commands to install the minimal dependencies for compiling and
installing the Git binaries:

$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel

$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

In order to be able to add the documentation in various formats (doc,
html, info), these additional dependencies are required (Note: users
of RHEL and RHEL-derivatives like CentOS and Scientific Linux will
have to enable the EPEL repository to download the docbook2X package):

$ sudo yum install asciidoc xmlto docbook2X

$ sudo apt-get install asciidoc xmlto docbook2x

Additionally, if you’re using Fedora/RHEL/RHEL-derivatives, you need
to do this

$ sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

due to binary name differences.

When you have all the necessary dependencies, you can go ahead and
grab the latest tagged release tarball from several places. You can
get it via the Kernel.org site, at https://www.kernel.org/pub/software/scm/git, or the mirror on the GitHub web site, at https://github.com/git/git/releases. It’s generally a little clearer what the latest version is on the GitHub page, but the kernel.org page also has release signatures if you want to verify your download.

Then, compile and install:

tarzxfgit2.0.0.tar.gz cd git-2.0.0
makeconfigure ./configure –prefix=/usr
makealldocinfo sudo make install install-doc install-html install-info

After this is done, you can also get Git via Git itself for updates:

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

总结其重要的几步:

  1. 确定安装环境,如Linux、Windows系统类别和系统版本;
  2. 确定Git版本,根据不同需要,新特性尝试、稳定版、企业试用等等,选择不同Git版本;
  3. 根据Git版本选择相应依赖,并安装相关依赖;
  4. 安装Git,并配置Git的环境变量
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值