Last active
August 29, 2015 14:17
Revisions
-
cybertk revised this gist
Mar 26, 2015 . 1 changed file with 14 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,12 @@ #!/bin/sh # # Copy a remote git repo to another remote destination # https://gist.github.com/cybertk/8a61ed9aca71a66cd711 # # Copyright (C) 2015 Quanlong <[email protected]> set -e # Options validation if [ -z "$1" -o -z "$2" ]; then @@ -14,14 +17,19 @@ fi SRC_REPO=$1 DST_REPO=$2 # Clone source into temp working dir repo_name=`mktemp -d -t ck-git-copy` git clone --mirror ${SRC_REPO} ${repo_name} pushd ${repo_name} > /dev/null # Update local refs git fetch --prune --progress git fetch --prune --tags --progress # Push to destination echo "Pushing to ${DST_REPO}" git push -f --prune ${DST_REPO} +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/* # Recovery popd > /dev/null rm -rf ${repo_name} -
cybertk created this gist
Mar 26, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/bin/sh # # Copy a remote git repo to another remote destination # # Copyright (C) 2015 Quanlong <[email protected]> # Options validation if [ -z "$1" -o -z "$2" ]; then echo "Usage: git copy <source_repo_url> <destionation_repo_url>" exit 1 fi SRC_REPO=$1 DST_REPO=$2 # Clone a bare repo repo_name="${SRC_REPO##*/}" [[ -d "${repo_name}" ]] || git clone --mirror ${SRC_REPO} cd ${repo_name} # Update local refs git fetch --prune --progress git fetch --prune --tags --progress # Push to another repo for mirrors git push --prune ${DST_REPO} +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*