Migrating a Git repository from one server to another.
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.
[shell]git clone –bare –mirror gitrepourl.git repo.git [/shell]
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.
[shell]cd repo.git [/shell]
3) Push complete mirror to another git server.
[shell]git push –mirror gitrepourl [/shell]
And it’s done, a git repo migrated from one server to another.
thanks a lot