LoginSignup
30
37

More than 5 years have passed since last update.

CentOS7に最新のGitをインストール、アップデート、他

Last updated at Posted at 2015-08-24

最新のGit(2.9.0)をCentOS7にインストール & アップデート

  • vagrant
  • CentOS 7.0
  • Git 2.9.0

パッケージマネージャーの古いバージョンを削除

必要に応じて古いバージョンは消します。

yum -y remove git.x86_64

Gitのコンパイルで必要なものをインストール

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

ソースを取得A(Binaryをダウンロード)

cd /usr/local/src/
curl -o git-2.9.0.tar.gz  https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz
tar vfx git-2.9.0.tar.gz

ソースを取得B(gitでgitをClone)

git clone https://github.com/git/git   # gitをclone  
cd git/                                # 
git checkout v2.9.0                    # v2.9.0をチェックアウト

コンパイル

cd git-2.9.0
make prefix=/usr/local all
make prefix=/usr/local install

確認

git --version
> git version 2.9.0

Extra

Beautiful diff

cd git
cp contrib/diff-highlight/diff-highlight /usr/local/bin/
~/.gitconfig
[pager]
    log = diff-highlight | less
    show = diff-highlight | less
    diff = diff-highlight | less
[interactive]
    diffFilter = diff-highlight

補完, プロンプト

cd git
cp contrib/completion/git-prompt.sh ~/.git-prompt.sh
cp contrib/completion/git-completion.bash ~/.git-completion.bash
~/.bashrc
# Source git completion
if [ -f ~/.git-completion.bash ]; then
    . ~/.git-completion.bash
fi
# Source git prompt
if [ -f ~/.git-prompt.sh ]; then
    GIT_PS1_SHOWDIRTYSTATE=1
    . ~/.git-prompt.sh
    PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
fi

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