参考:腾讯云手动实验:https://cloud.tencent.com/developer/labs/lab/10045
下载安装Git
Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。
安装依赖库
[root@localhost ~]# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
安装编译工具
[root@localhost ~]# yum -y install gcc perl-ExtUtils-MakeMaker
下载git软件包
wget https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz
解压和编译
[root@localhost ~]# tar zxf git-2.10.0.tar.gz
[root@localhost ~]# cd git-2.10.0/
[root@localhost git-2.10.0]# make all prefix=/usr/local/git
[root@localhost git-2.10.0]# make install prefix=/usr/local/git
配置环境变量
[root@localhost ~]# echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
[root@localhost ~]# source /etc/bashrc
[root@localhost ~]# git --version
git version 1.8.3.1
创建Git账号密码
[root@localhost ~]# useradd -m zx
[root@localhost ~]# passwd zx
更改用户 zx 的密码 。
新的 密码:
无效的密码: 密码未通过字典检查 - 过于简单化/系统化
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
初始化git仓库并配置用户权限
创建git仓库并初始化
[root@localhost ~]# mkdir -p /data/repositories
[root@localhost ~]# cd /data/repositories/
[root@localhost repositories]# git init --bare test.git
初始化空的 Git 版本库于 /data/repositories/test.git/
配置用户权限
[root@localhost ~]# chown -R zx:zx /data/repositories/
[root@localhost ~]# chmod 755 /data/repositories/
更改用户的shell环境
[root@localhost ~]# which git-shell
/usr/bin/git-shell
[root@localhost ~]# vim /etc/passwd
为了安全起见,此用户只能登陆git-shell
zx:x:1001:1001::/home/zx:/usr/bin/git-shell
使用git
[root@localhost ~]# git clone zx@1.1.1.5:/data/repositories/test.git/