Skip to content
Snippets Groups Projects

github gitlab repository mirroring

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Claudio Pisa

    A script to mirror a github repository into a gitlab repository (one way). The user running the script should be enabled to write to the repository through SSH.

    repomirror.sh 365 B
    #!/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
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment