{"id":19544479,"url":"https://github.com/selectnull/bitbucket-migration","last_synced_at":"2026-05-15T10:37:55.641Z","repository":{"id":145325710,"uuid":"266750939","full_name":"selectnull/bitbucket-migration","owner":"selectnull","description":"Set of bash scripts to migrate mercurial and git repositories from bitbucket to github.","archived":false,"fork":false,"pushed_at":"2020-06-02T18:22:57.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T02:55:37.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selectnull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-25T10:30:13.000Z","updated_at":"2020-07-26T12:56:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba5fc23f-251f-45f2-b591-12e9ad6278ac","html_url":"https://github.com/selectnull/bitbucket-migration","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectnull%2Fbitbucket-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectnull%2Fbitbucket-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectnull%2Fbitbucket-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selectnull%2Fbitbucket-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selectnull","download_url":"https://codeload.github.com/selectnull/bitbucket-migration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240801037,"owners_count":19859727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T03:29:07.036Z","updated_at":"2026-05-15T10:37:50.573Z","avatar_url":"https://github.com/selectnull.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"bitbucket to github migration\n=============================\n\n[Bitbucket has announced sunsetting Mercurial support](\n(https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket)\nand they will delete all mercurial repositories by July 1, 2020.\n\nI can quite honestly understand the bitbucket decision, mercurial simply\ndidn't win enough source control market share and to support it has its\ncosts (and to deprecate it has its consequences).\n\nThis is a set of bash scripts to migrate mercurial and/or git\nrepositories hosted at bitbucket.org to github.com. The code has been\ntested and works, but it's not really meant to be used without\nunderstanding of how it works. Feel free to modify for your own needs.\n\nRequirements\n------------\n\nThese scripts require bash (probably work in other shells but I haven't\ntested it) with few external dependencies:\n\n* git\n* hg\n* jq\n* python\n* diff\n* fast-export\n\n\nClone repositories from bitbucket\n---------------------------------\n\nWe'll use bitbucket API to get a list of all repositories and for that\nwe need to create app password to access the data. App passwords are\ndefinitely easier to use than OAuth2. Go to [bitbucket\nsettings](https://bitbucket.org/account/settings/app-passwords/) and\ncreate new app password. After the migrations is done, you can delete\nit. Create a file called `.bitbucket-credentials` with this content:\n\n    USERNAME|PASSWORD\n\nAfter that, run a script to clone all repositories locally.\n\n    ./clone-from-bitbucket.sh --team TEAM --output-dir PATH-TO-EMPTY-OUTPUT-DIRECTORY\n\nYou will get a mix of `git` or `hg` repositories.\n\nConvert hg to git\n-----------------\n\nOnce you have all the repositories, you need to convert `hg`\nrepositories to `git`. Conversion is done by excellent\n[fast-export](https://github.com/frej/fast-export) tool. Clone it\nlocally and follow its install instructions. I recommend you\ninstall `mercurial` into empty python virtual environment\nso you don't clutter the system packages but that's optional.\n\nRun the script with:\n\n    ./convert-hg-to-git.sh \\\n        --sourcedir PATH-TO-CLONED-BITBUCKET-REPOSITORIES \\\n        --targetdir PATH-TO-EMPTY-DIR \\\n        --fast-export PATH-TO-FAST-EXPORT-PROGRAM\n        --fast-export-venv PATH-TO-VIRTUAL-ENVIRONMENT\n\nThis will convert all mercurial repositories from `sourcedir` to `git`\nand save them to `targetdir`. Any `git` repository will be skippped.\n\nYou can check that everything has been converted properly with:\n\n    ./diff-dirs.sh PATH-TO-CLONED-BITBUCKET-REPOSITORIES PATH-TO-CONVERTED-GIT-REPOSITORIES\n\nCreate empty repositories on Github\n-----------------------------------\n\nYou need a repository to push the code to, so let's create them. This\ntime we'll use Github API and you (just like with bitbucket) need to\ncreate [personal access token](https://github.com/settings/tokens).\nCreate a file `.github-credentials` with the content:\n\n    USERNAME|PASSWORD\n\nRun the script:\n\n    ./create-github-repo.sh --organization ORGANIZATION --source-dir PATH-TO-GIT-REPOSITORIES\n\n\nPush to github\n--------------\n\nFinally, you need to push the code to github.\n\n    ./push-to-github.sh --source-dir PATH-TO-GIT-REPOSITORIES\n\nIf you had a mix of git and hg repositories, following these scripts\nwould have created two different root directories where repository are,\nso you would need to run this script for both paths.\n\n\nLicence\n-------\n\nThe code in this repository is MIT licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselectnull%2Fbitbucket-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselectnull%2Fbitbucket-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselectnull%2Fbitbucket-migration/lists"}