{"id":136,"date":"2014-07-21T02:17:15","date_gmt":"2014-07-20T22:17:15","guid":{"rendered":"http:\/\/www.cocoaminers.com\/?p=136"},"modified":"2015-04-06T20:13:22","modified_gmt":"2015-04-06T18:13:22","slug":"transferring-files-between-git-repositories-including-history","status":"publish","type":"post","link":"https:\/\/www.cocoaminers.com\/?p=136","title":{"rendered":"Transferring files between git repositories including history"},"content":{"rendered":"<p>Sometimes you have to transfer a file from one GIT repository to the other. You also need to preserve the history, either to give credits to authors, or simply to know why certain parts of code do exist.<\/p>\n<p>First you have to export all desired files in a patch. Make sure you are running this command from git repository directory:<\/p>\n<p><strong>git log &#8211;pretty=email &#8211;patch-with-stat &#8211;reverse &#8211;full-index &#8211;binary &#8212; <\/strong><em>&lt;file or directory&gt;<strong>\u00a0&gt; <\/strong>&lt;patch filename&gt;<\/em><\/p>\n<p>the patch now contains all commits containing changes to specified files. The next step is to navigate to target repo directory and apply patch:<\/p>\n<p><strong>git am &#8211;committer-date-is-author-date &lt;<\/strong>\u00a0<em>&lt;patch filename&gt;<\/em><\/p>\n<p>committer&#8230; flag forces commits from patch to maintain their original dates. Otherwise all applied commits would have current date. Sometimes you get a message:<\/p>\n<p><em>Patch is empty.\u00a0 Was it split\u00a0wrong?<\/em><\/p>\n<p><em>If you would prefer to skip this patch, instead run &#8220;git am &#8211;skip&#8221;.<\/em><\/p>\n<p><em>To restore the original branch and stop patching run &#8220;git am &#8211;abort&#8221;.<\/em><\/p>\n<p>The reason might be that there are merge commits without actual changes\u00a0in the history. If you encounter this error just skip empty commits\u00a0using<\/p>\n<p><strong>git am &#8211;skip &#8211;committer-date-is-author-date<\/strong><\/p>\n<p>make sure to include &#8211;committer flag, otherwise all consequent commits would have todays date.<!--53f22acc149941408379596--><\/p>\n<div style=\"display: none;\">\u0413\u0440\u0430\u043c\u043e\u0442\u043d\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0438 \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u043f\u0440\u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u0441\u0430\u0439\u0442\u0430 \u0438 \u0440\u0430\u0441\u043a\u0440\u0443\u0442\u043a\u0435 \u0435\u0433\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 <a style=\"display: none;\" href=\"http:\/\/topodin.com\/test_final\/consultant.php\" rel=\"nofollow\">topodin<\/a>, \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043b\u0438 \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u044f\u0449\u0438\u043a\u0443<\/div>\n<p><!--\/53f22acc149941408379596--><!--54a40bad830451420037037--><a style=\"display: none;\" title=\"\u043f\u0440\u0438\u0432\u0430\u0442\u0431\u0430\u043d\u043a \u043a\u0443\u0440\u0441\u043a \u043a\u0430\u0440\u0442\u0430 \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u0430\u044f\" href=\"http:\/\/evolutioncloud.com\/privatbank-zayavka-na-kreditnuyu-kartu.php\">evolutioncloud.com \u043f\u0440\u0438\u0432\u0430\u0442\u0431\u0430\u043d\u043a \u043a\u0443\u0440\u0441\u043a \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0430<\/a><!--\/54a40bad830451420037037--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you have to transfer a file from one GIT repository to the other. You also need to preserve the history, either to give credits to authors, or simply to know why certain parts of code do exist. First you have to export all desired files in a patch. Make sure you are running this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-136","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=\/wp\/v2\/posts\/136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=136"}],"version-history":[{"count":5,"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=\/wp\/v2\/posts\/136\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=\/wp\/v2\/posts\/136\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cocoaminers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}