LoginSignup
7
7

More than 3 years have passed since last update.

LinuxサーバにGitの最新バージョンを導入する

Last updated at Posted at 2020-01-24

はじめに

  • Linuxで(Linuxに限らずだけれど)Gitをパッケージインストール(yum install gitなど)すると,古いものしか入らない.
  • バージョンアップしやすい形で最新版をインストールする方法を記述する(他の人も同じこと書いてるけれど,参照しやすいように).
  • 参考サイト

作業の手順

# 事前に時刻合わせをしておかないとエラーになる可能性がある

# 依存ライブラリをインストール
sudo yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker gcc

# Gitをインストール(今回はここで入れたgitは後でアンインストールする)
sudo yum -y install git

# rootにスイッチ
sudo su -

# 以下の作業はすべてrootで実行.

# ソースディレクトリまで移動
cd /usr/local/src/
# 公開されているgitのソースをインストール(この作業のために上記でGitをインストールした)
git clone git://git.kernel.org/pub/scm/git/git.git

# パッケージインストールしているgitをアンインストール
yum remove git

# ディレクトリ移動
cd git

# makeする
make prefix=/usr/local all
make prefix=/usr/local install

これ以降、最新バージョンが公開されるたびに、git pullしてmake~すれば最新バージョンにアップデートできる.

7
7
1

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
7
7