{"id":7697,"date":"2012-09-18T21:40:08","date_gmt":"2012-09-18T16:10:08","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=7697"},"modified":"2016-12-19T15:06:31","modified_gmt":"2016-12-19T09:36:31","slug":"migrate-git-repository-from-one-server-to-other","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/migrate-git-repository-from-one-server-to-other\/","title":{"rendered":"Migrating a Git repository from one server to another."},"content":{"rendered":"<p>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&#8217;s a very simple three step process.<\/br><br \/>\n<strong>1) Clone bare structure of an existing repository with full source.<\/strong><br \/>\n[shell]git clone &#8211;bare &#8211;mirror gitrepourl.git repo.git [\/shell]<br \/>\nThe option &#8211;bare will make a bare repository with the specified name that is \u201crepo.git\u201d in this case.And the option \u2013 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<\/br><br \/>\n<strong>2) Step into folder created.<\/strong><br \/>\n[shell]cd repo.git [\/shell]<br \/>\n<strong>3) Push complete mirror to another git server.<\/strong><br \/>\n[shell]git push &#8211;mirror gitrepourl [\/shell]<br \/>\nAnd it&#8217;s done, a git repo migrated from one server to another.<\/p>\n<div>_________________________________<\/div>\n<div>Hitesh Bhatia<br \/>\n<a href=\"mailto:hitesh@intelligrape.com\" target=\"_blank\">Mail<\/a> LinkedIn,<a href=\"http:\/\/www.facebook.com\/home.php?#%21\/profile.php?id=100000114437286\" target=\"_blank\">Facebook<\/a>,<a href=\"http:\/\/twitter.com\/d1_ricky\" target=\"_blank\">Twitter<\/a><br \/>\n_________________________________<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s a very simple three step process. [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":65},"categories":[1],"tags":[987,375,503,986,988,985],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/7697"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=7697"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/7697\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=7697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=7697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=7697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}