How to make a GitHub mirror to Bitbucket?

You could simply add a second remote:

git remote add bitbucket /url/to/am/empty/bitbucket/repo

and push everything to bitbucket:

git push --mirror bitbucket

You can actually pull from or push to multiple remotes from your local repo.


Update 2020:

As noted below in Rahulmohan Kolakandy's answer, if you are talking about an on-premise BitBucket server (as opposed to bitbucket.org), then you can take advantage of BitBucket Server Smart Mirroring.

As commented by V-Q-A NGUYEN:

BitBucket Server Smart Mirroring (introduced originally in 2016, and Oct. 2017 for BitBucket Server)

is only available for customers with an active Bitbucket Data Center license


With Bitbucket Server, you can use ScriptRunner https://marketplace.atlassian.com/apps/1213250/scriptrunner-for-bitbucket-server-stash?hosting=server&tab=overview

Full Disclosure: I work for them :)


The method explained here is better https://stackoverflow.com/a/12795747/988941

git remote set-url origin --add https://bitbucket.org/YOU/YOUR_REPO.git

Recent version of git handle multiple URLs in the same origin ;)


you no longer have to create these mirror links. Bitbucket has come up with this concept of smart mirror which does a real time sync to your mirror server.

More read here https://confluence.atlassian.com/bitbucketserver/smart-mirroring-776640046.html

Hope this helps!