[传送门]-自建git服务

2018-03-24  本文已影响0人  soar1997

0.忍无可忍

博主在本地写好代码就直接git push到github上去,然后在web服务器上直接git pull更新web代码,这种模式用起来爽极了。但是最近两天,在web服务器上git pull的频繁失败,发现自己的腾讯云VPS直接ping不通github.com了,这更本无法忍受,因此决定直接在VPS上把git服务搭建起来。

参考Git 服务器搭建Linux使用ssh公钥实现免密码登录Linux

1.Git Server On VPS(CentOS)

# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
# yum install git
# groupadd git
# useradd git -g git
# mkdir /home/gitrepo
# chown git:git /home/gitrepo/
# cd /home/gitrepo
# git init --bare wuaiwulu2.git
# git chown -R git:git wuaiwulu2.git

2.Workspace On Localhost(Archlinux)

$ cd ~/.ssh/
$ ssh-keygen

3.Web Server On VPS(CentOS)

# cd ~/.ssh/
# ssh-keygen

4.Git Server On VPS(CentOS)

# cd /home/git
# mkdir .ssh
# chmod 755 .ssh
# cat id_rsa.pub.soar >> .ssh/authorized_keys
# cat id_rsa.pub.root >> .ssh/authorized_keys
# chmod 644 .ssh/authorized_keys

4.转移文件开始下一行代码

然后就可以愉快地git clone git push git pull啦

$ git clone git@brocadesoar.cn:/home/gitrepo/wuaiwulu2.git
# git clone git@localhost:/home/gitrepo/wuaiwulu2.git
上一篇 下一篇

猜你喜欢

热点阅读