Bash script to help you copy/migrate all the repos (inc branches/tags) from one GH org to another
This script will attempt to:
- create a new directory with
SOURCE_ORG
name andcd
into it - clone all the repos (including branches/tags) from
SOURCE_ORG
- for each non empty repo:
- update the name of the repo if it doesn't start with
PREFIX
- create an empty repo in
TARGET_ORG
with the updated name and grantsTEAM_NAME
access to it - update the local repo's
remote origin
to point to new repo inTARGET_ORG
- push all branches/tags from local repo to new remote
- update the name of the repo if it doesn't start with
- Your github account is a member of both
SOURCE_ORG
andTARGET_ORG
- Migrated repos' names will be
PREFIX-ORIGINAL_NAME
TEAM_NAME
exists inTARGET_ORG
This script uses jq under the hood to parse response json payloads
You need to have access to both repositories and create an access token for your account. This token needs to have :
repo
: Grants read/write access to code, commit statuses, invitations, collaborators, adding team memberships, and deployment statuses for public and private repositories and organizationsread:org
: Read-only access to organization, teams, and membership
bash githoover.sh
If your repos have pull requests made to them, you will see errors like this:
! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
See this for more information.