ubuntu 编译安装最新版本的 git

ubuntu 通过 apt 方式安装的 git 版本比较低。

$ git --version
git version 2.25.1

没办法设置默认的主版本(main)

git clone https://github.com/git/git.git
cd git
sudo su
make prefix=/usr/local install install-doc install-html install-info

Q&A

  • 1
       GEN git-gui
        MSGFMT    po/ru.msg make[1]: *** [Makefile:254: po/ru.msg] Error 127
    make: *** [Makefile all] Error 2
apt install gettext -y
  • 2
    /bin/sh: 1: asciidoc: not found
apt install asciidoc -y
  • 3
    /bin/sh: 1: docbook2x-texi: not found
apt install docbook2x -y
  • 4
    git --version
    -bash: /usr/bin/git: No such file or directory
# 可以直接重启,或者执行以下命令创建软连接
$ ln -s /usr/local/bin/git /usr/bin/git
$ git --version
git version 2.33.0.328.g8b7c11b866