{"id":997,"date":"2012-10-18T22:47:17","date_gmt":"2012-10-19T06:47:17","guid":{"rendered":"http:\/\/www.wiredatom.com\/blog\/?p=997"},"modified":"2013-01-13T16:05:22","modified_gmt":"2013-01-14T00:05:22","slug":"moving-a-folder-from-one-git-repo-to-another-while-keeping-history","status":"publish","type":"post","link":"https:\/\/www.wiredatom.com\/blog\/2012\/10\/18\/moving-a-folder-from-one-git-repo-to-another-while-keeping-history\/","title":{"rendered":"Moving A Folder from One Git Repo to Another While Keeping History"},"content":{"rendered":"<p>Moving stuff from one git repo to another while keeping the history intact is a cool way to break stuff out of old repos and migrate them around. Here&#8217;s how to do it:<\/p>\n<div class=\"codecolorer-container bash railscasts\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"kw2\">git clone<\/span> <span class=\"re5\">--no-hardlinks<\/span> <span class=\"sy0\">\/<\/span>path<span class=\"sy0\">\/<\/span>to<span class=\"sy0\">\/<\/span>sourcerepository directory-to-move<br \/>\n<span class=\"kw3\">cd<\/span> directory-to-move<br \/>\n<br \/>\n<span class=\"co0\"># remove remote origin just so we can't break anything in the source repository<\/span><br \/>\n<span class=\"kw2\">git remote<\/span> <span class=\"kw2\">rm<\/span> origin<br \/>\n<br \/>\n<span class=\"co0\"># filter for desired files<\/span><br \/>\n<span class=\"kw2\">git filter-branch<\/span> <span class=\"re5\">--subdirectory-filter<\/span> new-directory-name HEAD<br \/>\n<br \/>\n<span class=\"co0\"># move around files, etc.<\/span><br \/>\n<span class=\"co0\"># then commit<\/span><br \/>\n<span class=\"kw2\">git add<\/span> .<br \/>\n<span class=\"kw2\">git commit<\/span> <span class=\"re5\">-m<\/span> <span class=\"st0\">&quot;isolated files&quot;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Refernece: <a href=\"http:\/\/www.martinahrer.at\/2012\/02\/15\/868\/\" title=\"Moving files from a Git repository to another keeping history\" target=\"_blank\">Moving files from a Git repository to another keeping history<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Moving stuff from one git repo to another while keeping the history intact is a cool way to break stuff out of old repos and migrate them around. Here&#8217;s how to do it: 12345678910111213git clone &#8211;no-hardlinks \/path\/to\/sourcerepository directory-to-move cd directory-to-move # remove remote origin just so we can&#8217;t break anything in the source repository git &hellip; <a href=\"https:\/\/www.wiredatom.com\/blog\/2012\/10\/18\/moving-a-folder-from-one-git-repo-to-another-while-keeping-history\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Moving A Folder from One Git Repo to Another While Keeping History&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10,4],"tags":[],"class_list":["post-997","post","type-post","status-publish","format-standard","hentry","category-geek-stuff","category-tips-tricks"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p54IqZ-g5","_links":{"self":[{"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/posts\/997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/comments?post=997"}],"version-history":[{"count":1,"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/posts\/997\/revisions"}],"predecessor-version":[{"id":1004,"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/posts\/997\/revisions\/1004"}],"wp:attachment":[{"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/media?parent=997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/categories?post=997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wiredatom.com\/blog\/wp-json\/wp\/v2\/tags?post=997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}