cw2030

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

需求:

需要定期把公网上的gitLab仓库的项目备份到本地的gitLab仓库

命令:

远程仓库镜像获取

git clone --mirror git@sourcehostname:root/financeData.git

或者

git clone --mirror http://sourcehostname/root/financeData.git

把镜像仓库推送到本地gitLab服务器

在本地gitLab仓库新建好空项目:root/financeData.git

git push --mirror git@targethostname:root/financeData.git

注意:目标服务器空项目创建好之后,进行项目文件夹目录再执行push命令。

更新远程仓库到本地仓库

1)先执行远程更新命令

git remote update

2)再执行推送命令

git push --mirror git@targethostname:root/financeData.git

 

注意:如果使用git@协议,需要事先把本地服务器的公钥上传到远程gitLab和本地gitLab服务器上,在个人设置的添加ssh-keys菜单项添加。

 

 

posted on 2018-03-13 11:21  cw2030  阅读(2579)  评论(0编辑  收藏  举报