How do I synchronise two remote Git repositories?

后端 未结 6 921
北荒
北荒 2020-12-24 08:40

I have two repository urls, and I want to synchronise them such that they both contain the same thing. In Mercurial, what I\'m trying to do would be:

hg pull         


        
6条回答
  •  难免孤独
    2020-12-24 08:58

    Here's a tested solution for the issue: http://www.tikalk.com/devops/sync-remote-repositories/

    The commands to run:

    #!/bin/bash
    
    # REPO_NAME=.git
    # ORIGIN_URL=git@:/$REPO_NAME
    # REPO1_URL=git@:/$REPO_NAME
    
    rm -rf $REPO_NAME
    git clone --bare $ORIGIN_URL
    cd $REPO_NAME
    git remote add --mirror=fetch repo1 $REPO1_URL
    git fetch origin --tags ; git fetch repo1 --tags
    git push origin --all ; git push origin --tags
    git push repo1 --all ; git push repo1 --tags
    

提交回复
热议问题