Git 简介与安装环境说明
1、简介
Git 是一款免费且开源的分布式版本控制软件,旨在以敏捷高效的方式处理规模各异的项目管理需求。
作为一个开源的分布式版本控制系统,Git 能够高效且快速地应对从小型到超大型项目的版本管理工作。
该工具由 Linux 之父 Linus Torvalds 开发,初衷是为了辅助 Linux 内核的开发工作,是一个开放源码的版本控制软件。
安装环境
测试平台为阿里云 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 文件。

执行该脚本后,根据屏幕提示输入相应内容即可完成操作。

命令行执行
git --version

安装完成。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。