Migrating a Git repository from one server to another.

18 / Sep / 2012 by Hitesh Bhatia 1 comments

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.

_________________________________
Hitesh Bhatia
Mail LinkedIn,Facebook,Twitter
_________________________________
FOUND THIS USEFUL? SHARE IT

comments (1 “Migrating a Git repository from one server to another.”)

Leave a Reply

Your email address will not be published. Required fields are marked *