Last active
June 3, 2019 08:50
-
-
Save dimkouv/8563abb0c1c47eecf9b048177996bf7b to your computer and use it in GitHub Desktop.
Mirror a git repository
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 characters
#!/bin/bash | |
# Mirror a git repository | |
# usage: ./gitmirror.sh <copied-repo> <mirror-repo> | |
# | |
# example: ./gitmirror.sh https://github.com/dimkouv/app https://gitlab.com/dimkouv/app | |
if [[ $# -ne 2 ]] ; then | |
echo 'Invalid arguments!' | |
exit 1 | |
fi | |
if [ -d "$1.git" ]; then | |
echo "ERROR: directory $1.git already exists"; | |
exit 1; | |
fi | |
git clone --bare $1.git; | |
repo=$1 | |
cd ${repo##*/}.git | |
git push --mirror $2.git; | |
cd ..; | |
rm -rf ${repo##*/}.git; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment