Migrate Git repository with complete commit history
·May 14, 2021·
1 min read
Have you ever wonder how to move your entire git repository from one git server to other with complete commit history manually, Either it can be from GitHub to Bitbucket or anything you name it .
It's not a big deal, You can do it in just 4 easy steps :)
git clone --mirror <url_of_old_repo> cd <name_of_old_repo> git remote add new-origin <url_of_new_repo> git push new-origin --mirror
Step1: Set up a mirror of the source repository which you wish to migrate, Clone with --mirror download including remote-tracking branches, tags, notes etc
git clone --mirror <url_of_old_repo>
Step2: Change directory and you can see following folders
Step3: Add new destination remote origin you wish to move to.
git remote add new-origin <url_of_new_repo>
Step4: Push entire repository to new origin, This might take a couple of minutes.
git push new-origin --mirror
That's it, Hope it helps. Let me know if you have better way to do it in comments below.