はじめに
この記事は、インストール直後のUbuntu Server 14.04 LTSへGitをインストールする為の手順書です。
私自身が実施した事の記録として、残します。
ゴール
読者が、「Ubuntu Server 14.04 LTSに、Gitをインストールできる」ようになる。
注意
- Gitがインストールされている場合は、本記事の手順に従ってインストールする前に、インストールされている古いGitをアンインストールする事
- インストール時に書庫を展開したディレクトリは、Gitをアンインストールするまで削除しない事
参考情報 : バージョンについて
インストールするバージョンは、https://www.kernel.org/pub/software/scm/git/ にある*.tar.gzから選択できる。
バージョンを、本記事に記載したバージョンから変える場合に、参考ください。
環境
- 実行環境 : Microsoft Azure(A0 Standard)
- OS : Ubuntu Server 14.04 LTS
- Git : 2.10.0
手順
0. 実行前
Gitのバージョンを確認しても、「git入ってないよ」と言われます。
$ git --version
The program 'git' is currently not installed. You can install it by typing:
sudo apt-get install git
1. Gitのmakeとインストール
rootで実行する為に、昇格します。
$ sudo su -
Gitインストールに必要なモジュールをインストールします。
# cd /
# apt-get install -y build-essential libssl-dev tcl8.4 tk8.4 gettext curl expat openssl zlibc libcurl4-openssl-dev
Gitの書庫ファイルをダウンロードし、インストールします。
# cd /usr/local/src/
# wget https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz
# tar zxf git-2.10.0.tar.gz
# cd git-2.10.0
# ./configure --prefix=/usr/local --with-curl --with-expat
# make all
# make install
または、以下の1行で
# cd /usr/local/src/ && wget https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz && tar zxf git-2.10.0.tar.gz && cd git-2.10.0 && ./configure --prefix=/usr/local --with-curl --with-expat && make all && make install
2. 実行後
バージョン確認とリポジトリから正しく取得できる事を確認します。
2-1. Gitのバージョン確認
Gitのバージョンを確認すると、インストールしたバージョンが出力されます。
$ git --version
git version 2.10.0
インストールしたバージョンが確認できたので、Gitのインストールに成功しています。
2-2. Gitリポジトリからのデータ取得
本記事では、GitHubからデータを取得する事で、正しくGitがインストールされたかをテストします。
$ git clone https://github.com/{your_account}/{your_repository}.git
Cloning into '{your_repository}'...
remote: Counting objects: 1520, done.
remote: Compressing objects: 100% (1007/1007), done.
remote: Total 1520 (delta 456), reused 1515 (delta 454), pack-reused 0
Receiving objects: 100% (1520/1520), 14.31 MiB | 2.51 MiB/s, done.
Resolving deltas: 100% (456/456), done.
Checking connectivity... done.
エラーが表示されずに、リポジトリからデータを取得できたので、Gitのインストールに成功しています。