Skip to content

Instantly share code, notes, and snippets.

@nuno-azevedo
Last active May 6, 2024 20:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save nuno-azevedo/fd6aa4ef0ccb153d5d375465b74158dd to your computer and use it in GitHub Desktop.
Save nuno-azevedo/fd6aa4ef0ccb153d5d375465b74158dd to your computer and use it in GitHub Desktop.
Import Repository from GitLab to GitHub
#!/bin/bash
# Arguments:
# ${1}: Username
# ${2}: Repository
# Clone the repo from GitLab using the `--mirror` option.
git clone --mirror "git@gitlab.com:${1}/${2}.git"
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
git -C "${2}" push --no-verify --mirror "git@github.com:${1}/${2}.git"
# Set push URL to the mirror location.
git -C "${2}" remote set-url --push origin "git@github.com:${1}/${2}.git"
# To periodically update the repo on GitHub with what you have in GitLab.
git -C "${2}" fetch -p origin
git -C "${2}" push --no-verify --mirror
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment