How to move repository from Bitbucket to GitHub with all branches and commits?

Step 1 : Create a Blank repository on Github without Readme.md

Creating blank repository on GitHub

Step 2 : Moving all code and content from bitbucket

  1. Check out the existing repository from Bitbucket:
$ git clone git@bitbucket.org:Cotocuschandan/testrepo.git

2. Now adding new GitHub Repository as upstream remote of the repository which is clone from bitbucket.

$ cd testrepo
$ git remote add upstream git@github.com:devops-school-com/ds-test.git

3. push all branches and tags to GitHub Repository using below commands

$ git push upstream master
$ git push --tags upstream

Step 3 : Add URL of New Github Repository as redirect URL

$ git remote set-url origin git@github.com:devops-school-com/ds-test.git

Step 4: At last Clone all branches and tags to GitHub Repository

$ git push --mirror

Thanks for reading above article. if you have any issue regarding above commands then please ask in the comment box. i will give you brief explanations on it.

Chandan Kumar
Follow Me: