Created
September 12, 2018 19:30
-
-
Save kg6zvp/db8d615fcf183ac606deb1e83f6daa05 to your computer and use it in GitHub Desktop.
Mirror a git repo up to github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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