因为嫌弃仓库里面的git版本太低,所以弄了一下源码安装,以deepin系统为例
参考资料
github源码地址:https://github.com/git/git
github releases地址:https://github.com/git/git/releases 在这个地址下载最新的源码包
安装步骤
- 下载源码包:到releases地址下载源码包,后缀为tar.gz
- 解压源码包:命令
tar -zxf git-2.21.0.tar.gz - 安装依赖包:参考地址:https://git-scm.com/book/zh/v1/起步-安装-Git
命令 apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
- 安装前说明:在源码文件中,有一个安装说明文件,文件名为
INSTALL,
地址:https://github.com/git/git/blob/master/INSTALL
截取部分内容如下
Git installationNormally you can just do "make" followed by "make install", and thatwill install the git programs in your own ~/bin/ directory. If you wantto do a global install, you can do$ make prefix=/usr all doc info ;# as yourself# make prefix=/usr install install-doc install-html install-info ;# as root(or prefix=/usr/local, of course). Just like any program suitethat uses $prefix, the built results have some paths encoded,which are derived from $prefix, so "make all; make prefix=/usrinstall" would not work.The beginning of the Makefile documents many variables that affect the waygit is built. You can override them either from the command line, or in aconfig.mak file.Alternatively you can use autoconf generated ./configure script toset up install paths (via config.mak.autogen), so you can write instead$ make configure ;# as yourself$ ./configure --prefix=/usr ;# as yourself$ make all doc ;# as yourself# make install install-doc install-html;# as rootIf you're willing to trade off (much) longer build time for a laterfaster git you can also do a profile feedback build with$ make prefix=/usr profile# make prefix=/usr PROFILE=BUILD installThis will run the complete test suite as training workload and thenrebuild git with the generated profile feedback. This results in a gitwhich is a few percent faster on CPU intensive workloads. Thismay be a good tradeoff for distribution packagers.Alternatively you can run profile feedback only with the git benchmarksuite. This runs significantly faster than the full test suite, buthas less coverage:$ make prefix=/usr profile-fast# make prefix=/usr PROFILE=BUILD installOr if you just want to install a profile-optimized version of git intoyour home directory, you could run:$ make profile-installor$ make profile-fast-installAs a caveat: a profile-optimized build takes a *lot* longer since thegit tree must be built twice, and in order for the profilingmeasurements to work properly, ccache must be disabled and the testsuite has to be run using only a single CPU. In addition, the profilefeedback build stage currently generates a lot of additional compilerwarnings.
- 习惯使用autoconf generated ./configure的方式安装,统一命令如下
注:在执行make configure的时候可能会报错,这个时候需要安装apt-get install autoconf
$ mkdir /usr/local/lib/git$ cd git-2.21.0$ make configure ;# as yourself$ ./configure --prefix=/usr/local/lib/git ;# as yourself$ make all doc ;# as yourself$ make install install-doc install-html;# as root
- 制作软连接
sudo ln -s /usr/local/lib/git/bin/git /usr/bin/git
