git 本地仓库同时推送到多个远程仓库

使用git把一个本地仓库同时push到多个远程仓库

1. 首先需要分别新建远程仓库

本次主要同时push到码云【gitee】和私有仓库【gitea】;

2. 从私有仓库【gitea】拉取代码到本地

# 从私有仓库【gitea】拉取代码到本地
$ git clone http://172.17.5.102:3001/jjxx/web-rydw.git

# 查看本地仓库关联的远程仓库情况
$ git remote -v
origin  http://172.17.5.102:3001/jjxx/web-rydw.git (fetch)
origin  http://172.17.5.102:3001/jjxx/web-rydw.git (push)

3. 添加新的远程码云【gitee】仓库

通过git remote set-url --add 别名 仓库地址添加新的远程仓库

$ git remote set-url --add origin https://gitee.com/gzjjxx/rydw.git

# 查看本地仓库关联的远程仓库情况
$ git remote -v
origin  http://172.17.5.102:3001/jjxx/web-rydw.git (fetch)
origin  http://172.17.5.102:3001/jjxx/web-rydw.git (push)
origin  https://gitee.com/gzjjxx/rydw.git (push)

 

4. 注意

本地仓库可以同时推送到私有仓库【gitea】和码云【gitee】,但只能从私有仓库【gitea】拉取

5. 可以通过直接修改.git/config文件来实现同样的功能

 

# 找到remote origin,添加url = 仓库地址
[remote "origin"]
        url = http://172.17.5.102:3001/jjxx/web-rydw.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://gitee.com/gzjjxx/rydw.git

 

posted @   IT民工郑小江  阅读(452)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示