Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Migrate or duplicate all GitHub repositories from one organization to another via SSH or HTTPS using an interactive Bash script, preserves full commit history, branches, and tags.

License

Notifications You must be signed in to change notification settings

umanda/github-org-repo-migrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

10 Commits

Repository files navigation

πŸ“¦ GitHub Org Repo Migrator (via SSH or HTTPS)

Easily migrate or duplicate all repositories from one GitHub organization to another using SSH or HTTPS. This Bash script is designed for engineers, DevOps, and org admins who want to bulk clone and push GitHub repositories from a source org to a target org, preserving all branches and tags using git clone --mirror.

✨ Features

  • βœ… Interactive CLI prompts
  • πŸ”„ Supports SSH or HTTPS cloning
  • πŸ“₯ Clone all or select repositories
  • πŸ” Preserves full Git history (branches + tags)
  • 🧼 Optional cleanup of temporary files
  • πŸ“¦ Works seamlessly with gh (GitHub CLI)

πŸ”§ Requirements

  • bash

  • git

  • GitHub CLI (gh) (must be authenticated)

    gh auth login
  • git with SSH or HTTPS access configured

  • Access to both source and target GitHub orgs

πŸš€ Usage

  1. Clone this repo:

    git clone git@github.com:yourusername/github-org-repo-migrator.git
    cd github-org-repo-migrator
  2. Make the script executable:

    chmod +x clone-github-repo.sh
  3. Run the script:

    ./clone-github-repo.sh
  4. Follow the interactive prompts:

    • Source organization
    • Target organization
    • SSH or HTTPS
    • Clone all or selected repositories
    • Cleanup confirmation

πŸ›  Example Workflow

./clone-github-repo.sh
πŸ”Ή Enter the source organization (e.g., org-x):
org-x
πŸ”Ή Enter the target organization (e.g., org-y):
org-y
πŸ”Ή Use SSH or HTTPS? (Enter 'ssh' or 'https'):
ssh
πŸ”Ή Do you want to clone all repos or selected repos only? (Enter 'all' or 'selected'):
all
...
🧼 Do you want to delete the temporary cloned repositories in 'temp_repos'? (yes/no):
yes

⚠️ Notes

  • git clone --mirror clones all branches, tags, and refs
  • The script uses gh repo create to create new private repos in the target org
  • You'll need proper permissions to both orgs for repo creation and cloning

πŸ“ Directory Structure

github-org-repo-migrator/
β”œβ”€β”€ clone-github-repo.sh # Main executable script
└── README.md # You're reading it!
└── LICENSE # License infomation
└── .gitignore # Let's not push all, this will help you to ignore unwanted files

πŸ“„ License

MIT License β€” feel free to fork, modify, and improve!

πŸ™Œ Acknowledgements

Built with πŸ’» for teams and org admins who love automation.

About

Migrate or duplicate all GitHub repositories from one organization to another via SSH or HTTPS using an interactive Bash script, preserves full commit history, branches, and tags.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /