Migration script for migrating to Forgejo from Github
Find a file
2026-04-01 17:31:32 +02:00
migrate.sh Initial commit. 2026-04-01 17:31:32 +02:00
README.md Initial commit. 2026-04-01 17:31:32 +02:00

GitHub to Forgejo Migration Script

Migrate repos from GitHub to a self-hosted Forgejo instance via SSH, verify the migration, then cleanly mark and archive the originals.

Usage

export FORGEJO_TOKEN="your-token-here"

./migrate.sh migrate   # Clone from GitHub, push to Forgejo
./migrate.sh verify    # Compare HEAD SHAs and branch counts
./migrate.sh mark      # Add migration notice + archive public repos on GitHub
./migrate.sh delete    # Delete private repos from GitHub (requires confirmation)

Prerequisites

  • SSH keys on both GitHub and Forgejo
  • gh CLI authenticated (gh auth login)
  • Forgejo API token with repo read/write permissions (FORGEJO_TOKEN)
  • curl, jq, git

Why this instead of Forgejo's built-in migration?

Forgejo can import repos directly from GitHub, including issues and PRs. Use that if you need to preserve them.

This script handles the full lifecycle when you just need the code: batch migrate, verify, add migration notices to the GitHub repos, archive them, and delete private ones — all in one tool.

Disclaimer

This script deletes repos and force-updates branches. It was written for a single migration and tested exactly once. It will not be maintained. Read it, understand it, and adjust it to your needs before running it. If it ruins your day, that's on you.

Customization

The repo list is fetched automatically from GitHub using gh repo list. Public forks are excluded. Edit FORGEJO_URL, FORGEJO_SSH, and GITHUB_USER in the script to match your setup.