Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 2.2 KB

README.md

File metadata and controls

56 lines (37 loc) · 2.2 KB

GitHoover

Bash script to help you copy/migrate all the repos (inc branches/tags) from one GH org to another

Description

This script will attempt to:

  • create a new directory with SOURCE_ORG name and cd 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 grants TEAM_NAME access to it
    • update the local repo's remote origin to point to new repo in TARGET_ORG
    • push all branches/tags from local repo to new remote

Assumptions

  • Your github account is a member of both SOURCE_ORG and TARGET_ORG
  • Migrated repos' names will be PREFIX-ORIGINAL_NAME
  • TEAM_NAME exists in TARGET_ORG

Dependencies

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 organizations
  • read:org: Read-only access to organization, teams, and membership

See github documentation here

Usage

bash githoover.sh

Note

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.

References