What's the proper way to transfer a complete Git repo from Bitbucket to GitHub?

I need to migrate my entire Git repository from Bitbucket over to GitHub. I want to make sure I don’t lose anything in the process - all my branches, commit history, tags, everything should come along.

I’ve been working on this project for months and have multiple feature branches that I still need. The main branch has a long history that I can’t afford to lose.

Can someone walk me through the steps to do this migration correctly? Are there any specific git commands I should run to ensure everything transfers properly? I’m worried about messing something up and losing my work.

I’ve heard there might be some automated tools or scripts that can help with this kind of repository migration, but I’m not sure which approach is the safest and most reliable.

i think the easiest way is cloning your bitbucket repo then just pushing to github. just do a regular clone, then add github as a remote with git remote add github <url>, and use git push github --all and git push github --tags. it’s way simpler than mirror cloning.

honestly just did this last week and had good luck with the mirror approach but make sure you delete the origin remote first before pushing to github.

so after git clone --mirror cd into the repo and do git remote rm origin then git remote add origin <your-github-url> and finally git push --mirror origin.

forgot that step initially and got some weird conflicts.

I’ve done this migration several times and found that using GitHub’s built-in importer is actually the most reliable method. Go to GitHub, create a new repository, and look for the “Import code” option during setup. You’ll just need to provide your Bitbucket repository URL and credentials. The advantage of this approach is that GitHub handles all the complexities automatically - branches, tags, commit history, everything gets transferred without you having to worry about command syntax or missing references. I’ve never had issues with data loss using their importer. If you prefer the command line route, definitely go with the mirror clone method mentioned above rather than regular cloning. Regular clones can sometimes miss remote tracking branches that aren’t checked out locally. After migration, always verify by comparing branch counts and checking a few random commit hashes between the old and new repos.

Migrating a Git repository from Bitbucket to GitHub can indeed be tricky. I recommend starting with a bare clone of your repository using git clone --mirror <bitbucket_repo_url>. Once you have that, you can push it to GitHub with git push --mirror <github_repo_url>. However, it’s crucial to verify if all branches, tags, and commit histories have been correctly transferred. After the migration, check your tags using git tag and push any missing ones with git push origin --tags. Also, be aware that some unique references, like pull requests, will not carry over as they are platform-specific. Lastly, review your branch protection settings in GitHub, as they may differ from what you had in Bitbucket.