在官网下载源码包
https://mirrors.edge.kernel.org/pub/software/scm/git/
编译安装
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 命令补全设置
cd ./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\][\u@\h \W \[\033[1;31m\]$(__git_ps1 "(git -> %s)")\[\e[1;32m\]]\$ \[\e[0m\]'
EOF