因为嫌弃仓库里面的git版本太低,所以弄了一下源码安装,以deepin系统为例

参考资料

github源码地址:https://github.com/git/git
github releases地址:https://github.com/git/git/releases 在这个地址下载最新的源码包

安装步骤

  1. 下载源码包:到releases地址下载源码包,后缀为tar.gz
  2. 解压源码包:命令 tar -zxf git-2.21.0.tar.gz
  3. 安装依赖包:参考地址:https://git-scm.com/book/zh/v1/起步-安装-Git

命令 apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev

  1. 安装前说明:在源码文件中,有一个安装说明文件,文件名为INSTALL

地址:https://github.com/git/git/blob/master/INSTALL
截取部分内容如下

  1. Git installation
  2. Normally you can just do "make" followed by "make install", and that
  3. will install the git programs in your own ~/bin/ directory. If you want
  4. to do a global install, you can do
  5. $ make prefix=/usr all doc info ;# as yourself
  6. # make prefix=/usr install install-doc install-html install-info ;# as root
  7. (or prefix=/usr/local, of course). Just like any program suite
  8. that uses $prefix, the built results have some paths encoded,
  9. which are derived from $prefix, so "make all; make prefix=/usr
  10. install" would not work.
  11. The beginning of the Makefile documents many variables that affect the way
  12. git is built. You can override them either from the command line, or in a
  13. config.mak file.
  14. Alternatively you can use autoconf generated ./configure script to
  15. set up install paths (via config.mak.autogen), so you can write instead
  16. $ make configure ;# as yourself
  17. $ ./configure --prefix=/usr ;# as yourself
  18. $ make all doc ;# as yourself
  19. # make install install-doc install-html;# as root
  20. If you're willing to trade off (much) longer build time for a later
  21. faster git you can also do a profile feedback build with
  22. $ make prefix=/usr profile
  23. # make prefix=/usr PROFILE=BUILD install
  24. This will run the complete test suite as training workload and then
  25. rebuild git with the generated profile feedback. This results in a git
  26. which is a few percent faster on CPU intensive workloads. This
  27. may be a good tradeoff for distribution packagers.
  28. Alternatively you can run profile feedback only with the git benchmark
  29. suite. This runs significantly faster than the full test suite, but
  30. has less coverage:
  31. $ make prefix=/usr profile-fast
  32. # make prefix=/usr PROFILE=BUILD install
  33. Or if you just want to install a profile-optimized version of git into
  34. your home directory, you could run:
  35. $ make profile-install
  36. or
  37. $ make profile-fast-install
  38. As a caveat: a profile-optimized build takes a *lot* longer since the
  39. git tree must be built twice, and in order for the profiling
  40. measurements to work properly, ccache must be disabled and the test
  41. suite has to be run using only a single CPU. In addition, the profile
  42. feedback build stage currently generates a lot of additional compiler
  43. warnings.
  1. 习惯使用autoconf generated ./configure的方式安装,统一命令如下

注:在执行make configure的时候可能会报错,这个时候需要安装apt-get install autoconf

  1. $ mkdir /usr/local/lib/git
  2. $ cd git-2.21.0
  3. $ make configure ;# as yourself
  4. $ ./configure --prefix=/usr/local/lib/git ;# as yourself
  5. $ make all doc ;# as yourself
  6. $ make install install-doc install-html;# as root
  1. 制作软连接

sudo ln -s /usr/local/lib/git/bin/git /usr/bin/git