Skip to content

Instantly share code, notes, and snippets.

@xtoddx
Last active January 14, 2016 21:30
Show Gist options
  • Save xtoddx/80846e6d1318d955dfe4 to your computer and use it in GitHub Desktop.
Save xtoddx/80846e6d1318d955dfe4 to your computer and use it in GitHub Desktop.
Notes on migrating repos from github

Notes on migrating repos from Github to AWS CodeCommit

Rationale

Github bills per repository. Moving unused repositories to an archival tier can reduce costs. You can still use Github for your daily flow, but not pay for untouched data.

Process

  • Clone a repository.
  • Clean branches.
  • Add the new remote and push master.
  • Push all other branches.
  • Backup issues & PRs.
  • Commit and push the issues/pr json files to aws
  • delete the github repository

deleting merged branches

git branch -r --merged | grep -v master | awk -F/ '{print ":"$2}' | xargs -n 1 git push -q origin

push branches

for x in `git branch -r | grep -v master | awk -F/ '{print $2}'` ; do git checkout -q $x ; git push -q aws $x ; done

(NOTE: I have push.default = current in my git config, otherwise you could probably do a single push after all the checkouts.)

backup issues

curl --user xtoddx:PASSWORD --header "X-GitHub-OTP: XXXXXX" https://api.github.com/repos/ORG/REPO/issues > gh-issues.json
curl --user xtoddx:PASSWORD --header "X-GitHub-OTP: XXXXXX" https://api.github.com/repos/ORG/REPO/pulls > gh-pull-requests.json

(NOTE: If you don't have two factor auth enabled, you don't need to pass the header. If you do this for many repos at one time, you may want to grab a more stable oauth token instead of constantly updating your OTP header.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment