gitlab远程服务器与本地服务器镜像备份


需求:

需要定期把公网上的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菜单项添加。

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM