Skip to main content

Scripts to assist with the migration of a Bitbucket git repository to GitHub.

Project description

Bitbucket → GitHub Migration Tools

This repository provides a set of Python-based tools and documentation to assist in migrating repositories from Bitbucket Cloud to GitHub. It covers the full process — from auditing and mirroring git history to migrating issues, pull requests, and attachments.

The goal is to provide a reliable, transparent, and repeatable migration workflow that minimizes manual steps while ensuring that all relevant metadata is preserved.


⚖️ Disclaimer

Migration Tools Created with Claude.ai

These migration tools were developed with assistance from Claude.ai, an AI language model by Anthropic. While every effort has been made to ensure the tools are reliable and safe:

  • Use at your own risk: Always perform a dry run (dry-run subcommand) before actual migration
  • Backup your data: Ensure you have backups of your Bitbucket repositories before migration
  • Review and verify: Carefully review the migration report and verify the results
  • Test thoroughly: Test the migration process in a non-production environment first

The tools follow a conservative migration strategy (e.g., closed PRs become issues rather than GitHub PRs) to minimize risks, but repository migrations involve complex metadata and edge cases that may require manual intervention.


✨ Features

  • 🆕 Unified Migration Toolkit: Single entry point with audit, migrate, dry-run, and test-auth subcommands
  • 🔍 Interactive Audit: Pre-migration analysis with automatic configuration generation and user prompting
  • 📊 Comprehensive Analysis: Repository structure, user activity, migration estimates, and gap detection
  • 🔄 Intelligent PR Migration: OPEN PRs with existing branches become GitHub PRs, others become issues (safest approach)
  • 🔗 Automatic Link Rewriting: Cross-references between issues/PRs are automatically updated to point to GitHub
  • 📎 Advanced Attachment Handling: Downloads all attachments and inline images with informative comments for manual upload
  • 👥 Smart User Mapping: Maps Bitbucket users to GitHub accounts with support for unmapped users and account ID resolution
  • 🧪 Dry-run Capability: Simulate entire migration without making changes to validate configuration
  • 📋 Comprehensive Reporting: Detailed markdown reports with migration statistics and troubleshooting notes
  • 🔢 Placeholder Issue Creation: Preserves original numbering with placeholders for deleted/missing content
  • 📄 Configuration Management: Generate and validate migration configurations automatically
  • 🛡️ Secure Token Handling: Environment variable support and token format validation
  • 📚 Step-by-step Documentation: Checklists and guides for every phase of the migration process

Architecture Benefits

  • Modular Design: Shared components eliminate code duplication between audit and migration
  • Single Source of Truth: Consistent API interactions, user mapping, and error handling
  • Easy Maintenance: Updates to core functionality benefit both audit and migration tools
  • Backward Compatibility: Legacy scripts still supported alongside new unified toolkit

📘 Documentation

Comprehensive documentation is available at:

👉 Bitbucket → GitHub Migration Guide

It includes:

  • Quick start instructions
  • Migration and verification guides
  • Troubleshooting steps
  • Configuration references
  • Pre-/post-migration checklists

🧰 Requirements

  • Python 3.12+
  • Git 2.x+
  • Bitbucket API token
  • GitHub Personal Access Token (with repo scope)

🚀 Quick Start

Unified Migration Toolkit (Recommended)

# 1. Install the package globally (recommended)
pipx install bitbucket-migration

# 2. Audit Bitbucket repo (generates configuration)
migrate_bitbucket_to_github audit --workspace WORKSPACE --repo REPO --email EMAIL

# 3. Edit configuration
vim migration_config.json

# 4. Run dry-run to validate
migrate_bitbucket_to_github dry-run --config migration_config.json

# 5. Run full migration
migrate_bitbucket_to_github migrate --config migration_config.json

# 6. Follow documentation for attachment upload and verification

Alternative: Clone from source

git clone https://github.com/fkloosterman/bitbucket-migration.git
cd bitbucket-migration

# Use unified toolkit
migrate_bitbucket_to_github audit --workspace WORKSPACE --repo REPO --email EMAIL

# Or use the short alias (after installing package)
pip install -e .
bb2gh audit --workspace WORKSPACE --repo REPO --email EMAIL

For full instructions, visit the Migration Guide.

Available Commands

# Show all available commands
migrate_bitbucket_to_github --help
# Or using the short alias
bb2gh --help

# Audit repository (interactive prompts for missing args)
migrate_bitbucket_to_github audit --workspace WORKSPACE --repo REPO --email EMAIL
# Or using the short alias
bb2gh audit --workspace WORKSPACE --repo REPO --email EMAIL

# Generate configuration from audit
migrate_bitbucket_to_github audit --workspace WORKSPACE --repo REPO --email EMAIL
# Or using the short alias
bb2gh audit --workspace WORKSPACE --repo REPO --email EMAIL

# Test authentication (Bitbucket and GitHub APIs)
migrate_bitbucket_to_github test-auth --workspace WORKSPACE --repo REPO --email EMAIL --gh-owner GH_OWNER --gh-repo GH_REPO

# Dry run migration (validate configuration)
migrate_bitbucket_to_github dry-run --config migration_config.json
# Or using the short alias
bb2gh dry-run --config migration_config.json

# Full migration
migrate_bitbucket_to_github migrate --config migration_config.json
# Or using the short alias
bb2gh migrate --config migration_config.json

# Migrate only issues
migrate_bitbucket_to_github migrate --config migration_config.json --skip-prs

# Migrate only pull requests
migrate_bitbucket_to_github migrate --config migration_config.json --skip-issues

🧩 Contributing

Contributions are welcome! See the issues page for open tasks or suggestions.


📄 License

This project is licensed under the MIT License — see the LICENSE file for details.


© 2025 Fabian Kloosterman. All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitbucket_migration-1.0.0.tar.gz (120.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitbucket_migration-1.0.0-py3-none-any.whl (148.2 kB view details)

Uploaded Python 3

File details

Details for the file bitbucket_migration-1.0.0.tar.gz.

File metadata

  • Download URL: bitbucket_migration-1.0.0.tar.gz
  • Upload date:
  • Size: 120.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.8

File hashes

Hashes for bitbucket_migration-1.0.0.tar.gz
Algorithm Hash digest
SHA256 079d6f22f0dbb56e63c7a7d303448c4dcd6b3e88d931b3ac2512674a6ba8c22d
MD5 bdec3a5c38a561e0911543c46cee4574
BLAKE2b-256 159f20f2547db550ba97986f2428bb016c1e8704fd9a2a5f96d8d8b227d793a5

See more details on using hashes here.

File details

Details for the file bitbucket_migration-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bitbucket_migration-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5bb116e1e3eb03de49707acb57944fd2b0135cc28541338b5474d0afc239688
MD5 bfc0c1f6f3ed151b1dbb19c70dde91dd
BLAKE2b-256 5e2c53c8ab3831057076411b654c0f458a7e4c2309421fb99f719a663bb7791f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page