需求:
需要定期把公网上的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菜单项添加。
做自己喜欢做的事。