centos 6.8安装git_Centos7.2配置git远程服务器

04e316fac59771272a24669c430b6463.png

1 - git安装及版本

Centos7.2默认自带的git版本是 1.8.3。高级功能中的worktree并不支持。

首先升级git版本。

yum install git

显然是不行的。因为系统repo内并没有git的新版本。因此需要使用包含有最新版本git的仓库。

How to install latest version of git on CentOS 7.x/6.x​stackoverflow.com
fef0a70adef381a66c688c65ec4453fb.png

You can use WANDisco's CentOS repository to install Git 2.x: for CentOS 6, for CentOS 7

Install WANDisco repo package:

yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm 
- or - 
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm 
- or - 
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm

Install the latest version of Git 2.x:

yum install git
git --version

As of 16 Jul. 2019, the latest available version from WANDisco is 2.22.0.

2 - 创建git用户并为其分配权限

groupadd git
useradd git -g git
passwd git // 为git设置密码。方便部署,使用账户密码访问仓库

vim /etc/passwd
// 修改其bash为 git-shells 禁止使用ssh远程登录服务器

a8ff96133b878be98d9194bf4c92597f.png
git账户的权限,目录,组,shell分配

经过上述步骤,准备好了所需要的一切配置。

3 - 创建裸仓库并提交代码

cd /home/git
mkdir -pv example.git
cd example.git
git init --bare

本地使用git-bash将仓库clone下来并操作。

git clone ssh://git@domain:[port]/home/git/example.git

如果连接正常,会提示输入git密码。就可以顺利clone远程服务器的仓库到本地。这是一个裸仓库,什么内容都没有。修改之后:

git add --all
git commit -m "test push code to remote server"
git push origin master

以上就是全部内容,happy codding~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值