Migrate a Repository from Bitbucket to GitHub
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:
- https://bitbucket.org/account/settings/app-passwords/
- Or click the gear icon in the upper right →
Personal Bitbucket settings
→App passwords
on the sidebar
Click Create app password
. You'll see a screen like this (as of 2025-05-17):
Follow these steps to generate an app password:
- Fill in the details:
Label
: Enter any name (for your own reference).Permissions
: UnderRepositories
, checkRead
.
- 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:
- https://github.com/new/import
- Or click the
+
icon in the upper right →Import repository
You’ll see a screen like this (as of 2025-05-17):
Follow these steps to import the repository:
- Fill in the required information:
Your source repository details
The URL for your source repository
- Example:
https://bitbucket.org/USERNAME/REPOSITORY
- Example:
- 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
orPrivate
- Note: By default, the new repo will be public, so make sure to change this if needed
- 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)