如何编译安装最新的Git
Tofloor
poster avatar
deepinuser17
deepin
2019-09-29 22:40
Author
本帖最后由 deepinuser17 于 2019-9-30 11:38 编辑

深度自带的Git版本比较低。如果不想更改系统的软件包源地址,可以自己下载最新的Git版本的源文件(source tarball), 然后编译,安装。

1. 下载最新版本的源文件:访问https://github.com/git/git。 点击"Releases", 在v2.23.0版本号出现以后,点击右边的"zip", 下载源文件.  拷贝zip文件到/tmp

2. 编译安装

  1. sudo apt install autoconf gettext curl expat libcurl4-openssl-dev libssl-dev libexpat1-dev asciidoc

  2. cd /tmp
  3. unzip git-2.23.0.zip
  4. cd git-2-23.0
  5. make configure
  6. ./configure --prefix=/usr/local/git-2.23.0 --with-curl --with-expat
  7. make all
  8. make man
  9. sudo make install
  10. sudo make install-man
  11. sudo ln -s /usr/local/git-2.23.0 /usr/local/git
Copy the Code


3. 设定命令路径:

将下列加到~/.bashrc文件的末尾:
  1. export PATH=/usr/local/git/bin:$PATH
  2. export MANPATH=/usr/local/git/share/man:$PATH
Copy the Code

然后运行:
  1. source ~/.bashrc
  2. which git
  3. git --version
Copy the Code

4. 试验下载Git的开发源:
  1. git clone https://github.com/git/git
Copy the Code



Reply Favorite View the author
All Replies
avatar
funtoo
deepin
2019-09-29 23:35
#1
github的源代码包可以直接点击releases链接去下载指定的release版本,从tag里面找多费事。
而且我建议参考BLFS手册里面来编译安装:http://linuxfromscratch.org/blfs ... md/general/git.html。也不用担心文件散乱的问题,用porg记录一下就可以了。
Reply View the author
avatar
deepinuser17
deepin
2019-09-30 07:06
#2
本帖最后由 deepinuser17 于 2019-9-29 23:09 编辑

如果不想覆盖系统安装的Git, 或者被系统安装的Git覆盖,安装到分开的独立文件夹是最可靠的方法。 如果不再需要自己编译的Git,只需要删除编译安装的Git,取消~/.bashrc里的路径设置就好了。 否则自己安装的Git文件会散落到不同的地方。一般用dpkg无法列出自行安装的软件。
Reply View the author