207 字
1 分钟
自建服务器搭建git远程仓库
服务器操作
sudo yum install git
# 创建git用户sudo adduser git添加远程访问者的ssh密钥
在本地~/.ssh/id_rsa.pub中复制自己的ssh密钥到服务器/home/git/.ssh/authorized_keys中
# 本地执行,复制输出的密钥cat ~/.ssh/id_rsa.pub
# 服务器执行,将复制来的密钥添加到文件中,一个密钥一行vim /home/git/.ssh/authorized_keys创建git仓库
在~/ /home/git家目录下执行
mkdir gitrepo
# 创建一个裸仓库(没有工作区,只用于文件共享)git init --bare myrepo.git本地操作
A. 从新仓库开始(克隆)
git clone git@xxx.com:/home/git/gitrepo/myrepo.gitB. 为已有仓库添加新的远程仓库
# 添加远程仓库git remote add my_origin git@xxx.com:/home/git/gitrepo/myrepo.git
# 显示所有远程仓库配置git remote -v
# 展示远程仓库状态git remote show my_origin
# 推送到远程仓库,好耶!git push my_origin 自建服务器搭建git远程仓库
http://8.148.86.53/posts/git_origin_repo/