首页 > 其他分享 >git设置多个远程仓库

git设置多个远程仓库

时间:2023-01-29 10:56:54浏览次数:49  
标签:origin git remote 仓库 refs master https 远程

1. 添加多个远程仓库,单独push/pull

在添加的原有 origin 远程仓库之后,添加 mirror 远程仓库

git remote add mirror https://url2.com/my_repo.git

对应 .git/config

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://url1.com/my_repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[remote "mirror"]
    url = https://url2.com/my_repo.git
    fetch = +refs/heads/*:refs/remotes/mirror/*

push/pull操作

git pull origin master
git push origin master

git pull mirror master
git push mirror master

2. 原有远程仓库名下添加多个远程仓库

git remote set-url --add origin https://url1.com/my_repo.git

对应 .git/config

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://url1.com/my_repo.git
        url = https://url2.com/my_repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

3. https 远程仓库免密操作

.git/config配置文件修改

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://${user}:${password}@url1.com/my_repo.git
        url = https://${user}:${password}@url2.com/my_repo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

引用

标签:origin,git,remote,仓库,refs,master,https,远程
From: https://www.cnblogs.com/vaughnhuang/p/17072000.html

相关文章

  • 15年封神,GitHub开发者破亿!
    15年封神,GitHub开发者破亿!投递人 itwriter2 发布于 2023-01-2717:25 评论(0) 有1028人阅读 原文链接 [收藏] « »封神15年,GitHub用户现如今破了1......
  • Git命令
    环境配置//配置用户信息gitconfig--globaluser.name"name"gitconfig--globaluser.email"email"//查看所有用户配置gitconfig--list//查看user.name配......
  • 使用git和gitlab进行协同开发流程
    一、基本概念1.仓库(Repository)①源仓库(线上版本库)在项目的开始,项目的发起者构建起一个项目的最原始的仓库,称为​​origin。​​源仓库的有两个作用:1.汇总参与该项目的各......
  • 查看git的用户名和密码
    转载自:https://www.cnblogs.com/xihailong/p/13354628.html一、查看查看用户名:gitconfiguser.name查看密码:gitconfiguser.password查看邮箱:gitconfiguser.email查......
  • 浏览器网络诊断显示远程计算机或设备将不接受连接
    表现情况为:微信可以登录,但是浏览器无法上网,在浏览器上运行Windows诊断显示远程计算机或设备将不接受连接解决办法:1、Win+r打开运行,输入inetcpl.cpl,点击确定。......
  • ssh远程连接服务器
    远程连接服务器及压缩文件与解压1终端连接ssh-p端口号用户名@地址例如:ssh-p80name@host每次远程连接,使用账号和密码登录,有可能使得端口被监听到,从而导致挖......
  • setting.xml的mirror、mirrorOf和pom.xml的repositories、repository的关系关联snapsh
    setting.xml的mirror、mirrorOf和pom.xml的repositories、repository的关系关联snapshots带有时间错问题解决方案nexus3.8私有仓库https://blog.csdn.net/Michaelwubo/a......
  • netrw auto expand all node when using git difftool vimdiff compare two directoie
    匹配结点\v^(.([\.])@!)+\/$匹配节点,并展开:golobal/\v^(.([\.])@!)+\/$/exe"normal\<CR>"不过这里有个问题,展开过一次的节点,下次执行还会再展开一次,导致又关闭所......
  • 02pycharm 如何添加代码上传到gitlab
    1.首先正确安装好python,pycharm工具(这边不做介绍) 2.下载git的windows客户端官网:https://git-scm.com/download/win  根据自己的系统选择合适的版本,下载安装......
  • 如何解决github下载很慢的问题?(已经解决)
    目的是为了解决GitHub致命的下载速度慢的问题方法通过码云来导入github,通过码云下载1.在github上面找到自己想要的项目这一步略过2.复制github项目上面的网页链......