1、簡介
Git是一款免費、開源的分布式版本控制系統(tǒng),用于敏捷高效地處理任何或小或大的項目。
Git是一個開源的分布式版本控制系統(tǒng),用以有效、高速的處理從很小到非常大的項目版本管理。
Git 是 Linus Torvalds 為了幫助管理 Linux 內(nèi)核開發(fā)而開發(fā)的一個開放源碼的版本控制軟件
安裝環(huán)境
阿里云ECS CentOS 7.4 64位
2、使用shell安裝git
請將下載的shell與下面代碼保存到同一目錄
cnl_function.sh
#!/bin/bash
source ./cnl_function.sh
#function of installing git
install_git(){
#download the compressed package
cd /usr/local/src
#if compressed package is empty then download
[ -f git-2.2.1.tar.gz ] || wget https://www.kernel.org/pub/software/scm/git/git-2.2.1.tar.gz
check_ok
tar -zxf git-2.2.1.tar.gz
check_ok
[ -d /usr/local/git ] && mv /usr/local/git /usr/local/git_`date +%s`
cd git-2.2.1
check_ok
for p in expat-devel
do
myum $p
done
make prefix=/usr/local/git all
make prefix=/usr/local/git install
check_ok
if ! grep '^git:' /etc/group
then
groupadd git
fi
if ! grep '^git:' /etc/passwd
then
useradd -m git -s /usr/local/git/bin/git-shell -g git
fi
check_ok
ln -s /usr/local/git/bin/git /usr/local/bin/git
echo "git is installed finish."
}
read -p "Enter (Y) to start installation git :" n
if [ $n == 'Y' ]
then
echo "Start installation==============================================================================================================================>"
install_git
else
echo "Cancel the installation."
fi
如下圖,我將上面代碼保存位cnl_install_git.sh
![](/d/20211016/719ba638c4d3c49578f321b98ae85571.gif)
執(zhí)行腳本,按提示輸入即可
![](/d/20211016/281490f298b3f3a48030240e2f7cf941.gif)
命令行執(zhí)行
![](/d/20211016/fab5f1dec276eb4d54ff996e85374285.gif)
安裝完成。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。