Migrate a Repository from Bitbucket to GitHub

Posted: | Tags: Git

This article explains how to migrate a repository from Bitbucket to GitHub. The commit history will also be preserved during the migration.

Create an App Password on Bitbucket (for Private Repositories)

If your Bitbucket repository is private, you’ll need to generate an app password for authentication. This step is not required for public repositories.

Log in to Bitbucket and go to the app password creation page:

Click Create app password. You'll see a screen like this (as of 2025-05-17):

Bitbucket: The app password creation page

Follow these steps to generate an app password:

  1. Fill in the details:
    • Label: Enter any name (for your own reference).
    • Permissions: Under Repositories, check Read.
  2. Click Create to generate the password.
    • Important: The password will only be shown once. Copy and save it before closing the dialog.

You can delete the app password after the migration is complete.

Import the Repository into GitHub

Log in to GitHub and go to the repository import page:

You’ll see a screen like this (as of 2025-05-17):

GitHub: The repository import page

Follow these steps to import the repository:

  1. Fill in the required information:
    • Your source repository details
      • The URL for your source repository
        • Example: https://bitbucket.org/USERNAME/REPOSITORY
      • Important: If your source repository is private, also fill in the following:
        • Your username for your source repository
          • Your Bitbucket username
        • Your access token or password for your source repository
          • The Bitbucket app password you just created
    • Your new repository details
      • Repository name
      • Select either Public or Private
        • Note: By default, the new repo will be public, so make sure to change this if needed
  2. Click Begin import

You’ll receive an email once the import is complete. It’s safe to close the browser tab while the process is running.

Even small repositories can take a few minutes; larger ones may take longer.

Update the Remote URL in Your Local Repository

If you already have a local clone of the repository, you'll want to point it to the new GitHub remote.

Here’s how to update the remote URL (assuming the remote is named origin).

You can use either an SSH URL (git@github.com:USER/REPOSITORY.git) or HTTPS (https://github.com/USER/REPOSITORY.git), depending on your setup.

First, check the current remote URL with git remote -v:

$ git remote -v
origin  git@bitbucket.org:USER/REPOSITORY.git (fetch)
origin  git@bitbucket.org:USER/REPOSITORY.git (push)

Next, update the URL with git remote set-url:

$ git remote set-url origin git@github.com:USER/REPOSITORY.git 

Verify that the change took effect with git remote -v:

$ git remote -v
origin  git@github.com:USER/REPOSITORY.git (fetch)
origin  git@github.com:USER/REPOSITORY.git (push)

Related Categories

Related Articles