Recently, I had to migrate one of the git repository from our local git server to Github along with all the branches, tags etc. Since ours is a big project and with many branches, adding second remote and pushing master branch was not an option. And with Git it’s a very simple three step process.
1) Clone bare structure of an existing repository with full source.
git clone --bare --mirror gitrepourl.git repo.git
The option –bare will make a bare repository with the specified name that is “repo.git” in this case.And the option – mirror will set up a mirror of the source repository, it will not only clone branches of the source but also remote-tracking branches,tags etc
2) Step into folder created.
3) Push complete mirror to another git server.
git push --mirror gitrepourl
And it’s done, a git repo migrated from one server to another.