Git 源码编译安装

在官网下载源码包

https://mirrors.edge.kernel.org/pub/software/scm/git/

编译安装,此处演示2.27.0版本。

tar xf git-2.27.0.tar.gz
cd git-2.27.0
yum install gcc zlib-devel.x86_64
./configure --prefix=/usr/local/git && make && make install

Git 命令补全设置

./contrib/completion
mv git-completion.bash git-completion.sh
cp git-completion.bash git-prompt.sh /etc/profile.d/
cat << ‘EOF‘ > /etc/profile.d/git.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="verbose git svn"
export GIT_HOME=/usr/local/git
export PATH=$PATH:$GIT_HOME/bin
EOF

定制git命令提示符

cat << ‘EOF‘ >> /etc/bashrc
export PS1=‘\[\e[1;32m\][\\h \W \[\033[1;31m\]$(__git_ps1 "(git -> %s)")\[\e[1;32m\]]\$ \[\e[0m\]‘
EOF

Git 源码编译安装

相关推荐