Skip to content

Instantly share code, notes, and snippets.

@nuno-azevedo
Last active November 8, 2025 09:00
Show Gist options
  • Select an option

  • Save nuno-azevedo/fd6aa4ef0ccb153d5d375465b74158dd to your computer and use it in GitHub Desktop.

Select an option

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 "[email protected]:${1}/${2}.git"
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
git -C "${2}" push --no-verify --mirror "[email protected]:${1}/${2}.git"
# Set push URL to the mirror location.
git -C "${2}" remote set-url --push origin "[email protected]:${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