CentOS搭建Git服务器

参考:腾讯云手动实验: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/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值