Skip to content

Instantly share code, notes, and snippets.

@cl4u2
Created July 27, 2020 13:59
Show Gist options
  • Save cl4u2/6146a637ad77882e9b99c1d754b68e37 to your computer and use it in GitHub Desktop.
Save cl4u2/6146a637ad77882e9b99c1d754b68e37 to your computer and use it in GitHub Desktop.
One-way mirror of a github repository into a gitlab repository
#!/bin/bash
REPONAME=$1
SRCURL=$2
DSTURL=$3
if [ -z "$DSTURL" ]; then
echo "Usage: $0 <repository name> <github URL> <gitlab SSH URL>"
exit 1
fi
REPODIR=/home/gitlabmirror/repos/${REPONAME}.git
rm -rf $REPODIR
/usr/bin/git clone --bare $SRCURL $REPODIR
/usr/bin/git -C $REPODIR remote add gitlab $DSTURL
/usr/bin/git -C $REPODIR push --mirror gitlab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment