当前位置:   article > 正文

git 添加多个远程仓库_git连接多个远程仓库

git连接多个远程仓库
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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/989386
推荐阅读
相关标签
  

闽ICP备14008679号