LoginSignup
0

More than 5 years have passed since last update.

Organization

CentOS7.2に最新のGitをインストールする

CentOS7.2に最新のGitをインストールする

yumでインストールできるGitはバージョンが古くなっています。
インストールするならやっぱ最新がいいので手順をまとめます。

Gitをインストールする前にyumで依存パッケージをインストール

sudo yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker autoconf

最新のGitを取得し、解凍する

まず、Gitの最新バージョンを取得します。(執筆時の最新はv2.9.5でした)

cd /usr/local/src
sudo wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

ダウンロードが完了したら解凍します。

sudo tar vfx git-2.9.5.tar.gz > /dev/null

> /dev/nullはあってもなくても大丈夫です。(解凍状況を表示するかしないか)
tar.gzファイルを残しておくのが嫌な方はsudo rm -f git-2.9.5.tar.gzで削除しておきましょう。

コンパイルしてインストール

cd git-2.9.5
sudo make configure
sudo ./configure --prefix=/usr/local
sudo make all
sudo make install

既にyumでGitをインストールしている場合、削除しておきましょう。
sudo yum -y remove git

Gitコマンドを使えるようシンボリックリンクを作成

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

環境変数にパスを追加する方法もありだと思いますが、私はこちらが楽なのでいつもこの方法を使っています。

使えるようになっていることを確認して、完了

git --version
git version 2.9.5

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
0