{"id":906,"date":"2017-09-17T15:22:58","date_gmt":"2017-09-17T15:22:58","guid":{"rendered":"http:\/\/timony.com\/mickzblog\/?p=906"},"modified":"2017-09-17T15:24:39","modified_gmt":"2017-09-17T15:24:39","slug":"migrate-section-of-a-git-repo-to-a-new-git-repo","status":"publish","type":"post","link":"https:\/\/timony.com\/mickzblog\/2017\/09\/17\/migrate-section-of-a-git-repo-to-a-new-git-repo\/","title":{"rendered":"Migrate Section of a Git Repo to a new Git Repo"},"content":{"rendered":"<p class=\"p1\">I inherited a git repo that has multiple projects in it. It&#8217;s easier to manage the code and dependencies if each of these projects are in their own git repo.<\/p>\n<p>The process is pretty simple:<\/p>\n<ol>\n<li>Export the directory you plan to use as the starting point of the new repo<\/li>\n<li>Create the new repo<\/li>\n<li>Import the old repo<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-907 size-full\" src=\"http:\/\/timony.com\/mickzblog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-17-at-11.17.36-AM.png\" alt=\"\" width=\"1160\" height=\"64\" srcset=\"https:\/\/timony.com\/mickzblog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-17-at-11.17.36-AM.png 1160w, https:\/\/timony.com\/mickzblog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-17-at-11.17.36-AM-300x17.png 300w, https:\/\/timony.com\/mickzblog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-17-at-11.17.36-AM-768x42.png 768w, https:\/\/timony.com\/mickzblog\/wp-content\/uploads\/2017\/09\/Screen-Shot-2017-09-17-at-11.17.36-AM-1024x56.png 1024w\" sizes=\"auto, (max-width: 1160px) 100vw, 1160px\" \/><\/p>\n<ol>\n<li>Export the directory<\/li>\n<\/ol>\n<pre class=\"p1\">git log --pretty=email --patch-with-stat --reverse --full-index --binary DIRECTORY &gt; \/tmp\/DIRECTORY_patch;<\/pre>\n<p>2. Create the new repo<\/p>\n<pre class=\"p1\">git init REPONAME;<\/pre>\n<p>3. Import the old<\/p>\n<pre class=\"p1\">cd REPONAME;\r\n\r\ngit am &lt; \/tmp\/DIRECTORY_patch;<\/pre>\n<p>Run &#8216;git log&#8217; to verify that you&#8217;ve successfully import the repo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I inherited a git repo that has multiple projects in it. It&#8217;s easier to manage the code and dependencies if each of these projects are in their own git repo. The process is pretty simple: Export the directory you plan to use as the starting point of the new repo Create the new repo Import &hellip; <a href=\"https:\/\/timony.com\/mickzblog\/2017\/09\/17\/migrate-section-of-a-git-repo-to-a-new-git-repo\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Migrate Section of a Git Repo to a new Git Repo<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[690,33],"tags":[691,701,700,697,696],"class_list":["post-906","post","type-post","status-publish","format-standard","hentry","category-git","category-programming","tag-git","tag-git-export","tag-git-import","tag-source-control","tag-sourcecontrol"],"_links":{"self":[{"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/posts\/906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/comments?post=906"}],"version-history":[{"count":3,"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/posts\/906\/revisions"}],"predecessor-version":[{"id":910,"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/posts\/906\/revisions\/910"}],"wp:attachment":[{"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/media?parent=906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/categories?post=906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/timony.com\/mickzblog\/wp-json\/wp\/v2\/tags?post=906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}