Skip to content

Instantly share code, notes, and snippets.

@kg6zvp
Created September 12, 2018 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kg6zvp/db8d615fcf183ac606deb1e83f6daa05 to your computer and use it in GitHub Desktop.
Save kg6zvp/db8d615fcf183ac606deb1e83f6daa05 to your computer and use it in GitHub Desktop.
Mirror a git repo up to github
#!/bin/bash
# CI_REPOSITORY_URL: source repo
# DEST_REPO_URL: destination repo (ie: username/repo.git)
# GH_EMAIL: github e-mail
# GH_NAME: github name
# GITHUB_PERSONAL_ACCESS_TOKEN: github access token
# GH_USERNAME: github username
# SRC_BR: source branch
# DEST_BR: destination branch
git clone "$CI_REPOSITORY_URL" tmp_repo
cd tmp_repo
git config user.email "$GH_EMAIL"
git config user.name "$GH_NAME"
git checkout $SRC_BR
git remote add github "https://$GH_USERNAME:$GITHUB_PERSONAL_ACCESS_TOKEN@github.com/$DEST_REPO_URL"
git push --force github $DEST_BR
cd ..
rm -rf tmp_repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment