LoginSignup
9

posted at

updated at

Ubuntu で Git の最新を使う

git の バージョン

git をインストールすると、Ubuntu 20.04 の場合は、2.25.1 が入ります。(Ubuntu 18.04 は、2.17.1)

$ sudo apt install git
$ git version
git version 2.25.1

最新のGitを使いたい場合は ppa をリポジトリに追加すればOKです。

PPAを追加して git を更新する

ここでは、stable 版の ppa をリポジトリに追加していきます。

$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt update
$ sudo apt upgrade

現時点の最新

$ git version
git version 2.33.1

最新版 git 2.33.1 が無事入りました。

トラブルシューティング

ERROR: '~git-core' user or team does not exist. が出る場合

$ sudo add-apt-repository ppa:git-core/ppa
Cannot add PPA: 'ppa:~git-core/ubuntu/ppa'.
ERROR: '~git-core' user or team does not exist.

プロキシー環境下の場合に発生することがあります。
環境変数 http_proxy や https_proxy を引き継ぐようにするため sudo に -E オプションを渡すと良いです。

$ sudo -E add-apt-repository ppa:git-core/ppa

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
9