LoginSignup
1
0

More than 5 years have passed since last update.

CentOS に最新版の git をソースからインストールする手順

Last updated at Posted at 2017-10-29

作業メモ。

検証環境

bento/centos-7.3
vagrant ユーザーで作業。

手順

必要なものをインストール

パッケージ

git のリポジトリを引っ張ってくるために git が必要になるので,一旦 git も yum でインストールする。

$ sudo yum install -y autoconf curl-devel gcc git perl-ExtUtils-MakeMaker

$ which git
/usr/bin/git

$ git --version
git version 1.8.3.1

zlib-devel

git のビルドで必要になる zlib-devel をインストール。
参考ページ: https://qiita.com/shadowhat/items/867d9e06bc42cf862b9a

/usr/local/src が root の所有になっているけれど,make install 以外は root で作業したくないので,予め /usr/local/src を vagrant の所有にしておく。

$ sudo chown vagrant:vagrant /usr/local/src
$ cd /usr/local/src
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar zxvf zlib-1.2.11.tar.gz
$ cd zlib-1.2.11
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

git のリポジトリをクローン

$ cd /usr/local/src
$ git clone https://github.com/git/git
$ cd git
$ git tag
... 最新のタグを確認してチェックアウト
$ git checkout v2.9.5

yum でインストールした git を削除

チェックアウトまでできたら現行の git は削除する。
git の向き先が /bin/git に残っているので,削除後にシェルを再起動しておく。

$ sudo yum remove -y git
$ exec $SHELL -l

git のインストール

$ make configure
$ ./configure --prefix=/usr/local
$ make -j4
$ sudo make install

$ which git
/usr/local/bin/git

$ git --version
git version 2.9.5
1
0
0

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
  3. You can use dark theme
What you can do with signing up
1
0