Created
January 26, 2018 14:22
-
-
Save kidbrax/de315848842ac4f0ba140976e8e7d93d to your computer and use it in GitHub Desktop.
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
set -e | |
set -x | |
# 1. first, mark old repo as read-only so no new changes are added during transition | |
# we could script this too through github api. Note, do not lock repo here, since | |
# git clone will not work if you do. | |
# Make sure Repo doesn't have any active PRs. DO NOT migrate a repo with active Pull Requests. | |
# 2. change this. this is the name from <short_name>.git | |
# REPO_SHORT_NAME=sos | |
[[ -z "$REPO_SHORT_NAME" ]] && echo "REPO_SHORT_NAME can not be blank" && exit 1 | |
echo "using short name: $REPO_SHORT_NAME" | |
# 3. then, create the new empty repo in SAAS Github | |
# we could also script this through github api | |
# curl -H "Authorization: token <access_token>" https://api.github.com | |
curl \ | |
-X POST \ | |
-d '{ "name": '\"$REPO_SHORT_NAME\"', "private": true, "has_issues": false, "has_projects": false, "has_wiki": false }' \ | |
-H "Authorization: token <access_token>" \ | |
https://api.github.com/orgs/arthrex/repos | |
# do not change these | |
OLD_REPO=https://git.arthrex.io/marketing/$REPO_SHORT_NAME.git | |
NEW_REPO=https://github.com/arthrex/$REPO_SHORT_NAME.git | |
DIR=${OLD_REPO##*/} | |
# 4. then, migrate repo (don't do this from local repo, navigate to new directory) | |
git clone --bare $OLD_REPO | |
cd $DIR | |
git push --mirror $NEW_REPO | |
# 5. Have devs update their origin (issue this command from local repo) | |
git remote set-url origin $NEW_REPO | |
# 6. at this point, lock the old repo or just delete it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment