Skip to content

Migrate all git repositories from a BitBucket workspace to GitHub

License

Notifications You must be signed in to change notification settings

the-vaan-group/bitbucket-to-github

Repository files navigation

Bitbucket to Github Migration

This app transfers all of your Bitbucket repositories to Github while maintaining their privacy status.

For each repository, the app will perform the following:

  1. Clone all branches of the repository from Bitbucket;
  2. Create the repository with the same name on GitHub;
  3. Rename master branch to main;
  4. Create a placeholder master branch with no history to avoid accidental pushes;
  5. Push all branches to GitHub;
  6. Grant write permissions for a team if the repository belongs to an organization and the GITHUB_TEAM environment variable is set;
  7. Configure branch protection rules for the main branch and the placeholder master branch;
  8. Archive the repository if it was last updated more than one year ago;
  9. Delete repository on Bitbucket and set up a redirect notification with the new GitHub URL;

Getting Started

This app includes a Docker configuration that automatically installs all required dependencies.

Important! Before starting the migration, review the src/index.ts file and comment out the functions with the steps you don't wish to perform.

  1. Clone this repository:

    git clone https://github.com/the-vaan-group/bitbucket-to-github.git
    
  2. In the repository folder, create an environment variable file from the template:

    cp -iv .env.template .env
    
  3. Set the environment variables' values in the .env file.

  4. Start the Docker container:

    ./docker-up.sh
    
  5. After the Docker container is created, you should see the container's shell prompt. To start the migration type the following in the new shell prompt:

    npm run start
    

Helpful links

Create GitHub Personal Access token

Prior art

pouriaa/bitbucket-to-github