Skip to content

Instantly share code, notes, and snippets.

@ashwanth10
Forked from yorammi/2repos-sync.sh
Created October 19, 2020 07:32
Show Gist options
  • Save ashwanth10/bbc9f99a1a19d3b79d1d61a79c6ffb8b to your computer and use it in GitHub Desktop.
Save ashwanth10/bbc9f99a1a19d3b79d1d61a79c6ffb8b to your computer and use it in GitHub Desktop.

Revisions

  1. @yorammi yorammi revised this gist Nov 21, 2015. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions 2repos-sync.sh
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,43 @@

    rm -rf $REPO_NAME
    git clone --bare $ORIGIN_URL
    if [ "$?" != "0" ]; then
    echo "ERROR: failed clone of $ORIGIN_URL"
    exit 1
    fi
    cd $REPO_NAME
    git remote add --mirror=fetch repo1 $REPO1_URL
    if [ "$?" != "0" ]; then
    echo "ERROR: failed add remote of $REPO1_URL"
    exit 1
    fi
    git fetch origin --tags
    if [ "$?" != "0" ]; then
    echo "ERROR: failed fetch from $ORIGIN_URL"
    exit 1
    fi
    git fetch repo1 --tags
    if [ "$?" != "0" ]; then
    echo "ERROR: failed fetch from $REPO1_URL"
    exit 1
    fi
    git push origin --all
    if [ "$?" != "0" ]; then
    echo "ERROR: failed push to $ORIGIN_URL"
    exit 1
    fi
    git push origin --tags
    if [ "$?" != "0" ]; then
    echo "ERROR: failed push tags to $ORIGIN_URL"
    exit 1
    fi
    git push repo1 --all
    if [ "$?" != "0" ]; then
    echo "ERROR: failed push to $REPO1_URL"
    exit 1
    fi
    git push repo1 --tags
    if [ "$?" != "0" ]; then
    echo "ERROR: failed push tags to $REPO1_URL"
    exit 1
    fi
  2. @yorammi yorammi renamed this gist Nov 21, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @yorammi yorammi created this gist Nov 21, 2015.
    16 changes: 16 additions & 0 deletions repos-sync.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/bash

    # REPO_NAME=<repo>.git
    # ORIGIN_URL=git@<host>:<project>/$REPO_NAME
    # REPO1_URL=git@<host>:<project>/$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