{"id":17655,"date":"2013-01-09T02:26:25","date_gmt":"2013-01-09T00:26:25","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=17655"},"modified":"2013-01-09T02:26:25","modified_gmt":"2013-01-09T00:26:25","slug":"git-separating-folder-into-different-repository-with-history","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/","title":{"rendered":"Git : separating folder into different repository, with history"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>First things first. \u00a0If you don&#8217;t use git for version control yet, stop right now and go plan your migration. \u00a0You&#8217;ll thank me later. \u00a0Now. \u00a0A few days ago I had a tricky problem. \u00a0A chunk of code that was initially all over the project has been refactored into a pretty much separate library. \u00a0It was still a part of the same project, but in a folder of its own.<\/p>\n<p>Then, a realization came that this library can be used from a few other projects. \u00a0A separate git repository in combination with &#8216;<em>git submodule<\/em>&#8216; would do a better job. \u00a0But just initializing a new repository and copying files seemed like a bad hack. \u00a0We&#8217;d much rather keep all the commit history, contributors and timestamps. \u00a0But is that even possible?<\/p>\n<p>Turns out, it is. \u00a0And quite simple too. \u00a0<a href=\"http:\/\/stackoverflow.com\/questions\/359424\/detach-subdirectory-into-separate-git-repository\/6295550#6295550\">Stack Overflow<\/a> to the rescue. \u00a0I&#8217;ll copy the code here just in case it disappears.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ngit clone --no-hardlinks file:\/\/\/SOURCE \/tmp\/blubb\r\ncd blubb\r\ngit filter-branch --subdirectory-filter .\/PATH_TO_EXTRACT  --prune-empty --tag-name-filter cat -- --all\r\ngit clone file:\/\/\/tmp\/blubb\/ \/tmp\/blooh\r\ncd \/tmp\/blooh\r\ngit reflog expire --expire=now --all\r\ngit repack -ad\r\ngit gc --prune=now\r\n<\/pre>\n<p>It worked like a charm! The above lines gave me a local git repository with just the necessary folder and all the relevant commits&#8217; history. All I had to do after is add a remote repository and push the code to GitHub.<\/p>\n<p>This is one of those perfect examples of how powerful git is. \u00a0It&#8217;s also an example of git usage, which I would have probably never figured out on my own&#8230;<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>First things first. \u00a0If you don&#8217;t use git for version control yet, stop right now and go plan your migration. \u00a0You&#8217;ll thank me later. \u00a0Now. \u00a0A few days ago I had a tricky problem. \u00a0A chunk of code that was initially all over the project has been refactored into a pretty much separate library. \u00a0It &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Git : separating folder into different repository, with history<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[2265,1588],"keyring_services":[],"class_list":["post-17655","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-git","tag-version-control"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"First things first. If you don&#039;t use git for version control yet, stop right now and go plan your migration. You&#039;ll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Leonid Mamchenkov\"\/>\n\t<meta name=\"google-site-verification\" content=\"VHvdD0_usx1_4DzKy_QCVcICVgX2EgA2ybELT-wl7kQ\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Leonid Mamchenkov - Life, universe, and everything else\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Git : separating folder into different repository, with history - Leonid Mamchenkov\" \/>\n\t\t<meta property=\"og:description\" content=\"First things first. If you don&#039;t use git for version control yet, stop right now and go plan your migration. You&#039;ll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2026\/03\/leonid-sailing-beer.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2026\/03\/leonid-sailing-beer.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-01-09T00:26:25+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2013-01-09T00:26:25+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/MamchenkovBlog\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@mamchenkov\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Git : separating folder into different repository, with history - Leonid Mamchenkov\" \/>\n\t\t<meta name=\"twitter:description\" content=\"First things first. If you don&#039;t use git for version control yet, stop right now and go plan your migration. You&#039;ll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@mamchenkov\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2026\/03\/leonid-sailing-beer.jpg\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#blogposting\",\"name\":\"Git : separating folder into different repository, with history - Leonid Mamchenkov\",\"headline\":\"Git : separating folder into different repository, with history\",\"author\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/author\\\/leonid\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#articleImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3cf6df002a284d78fb6e9d8222ca4d102e0832035ed6bc8447008bd234e131a4?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Leonid Mamchenkov\"},\"datePublished\":\"2013-01-09T02:26:25+02:00\",\"dateModified\":\"2013-01-09T02:26:25+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#webpage\"},\"articleSection\":\"All, Programming, Technology, git, version control\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/programming\\\/#listItem\",\"name\":\"Programming\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/programming\\\/#listItem\",\"position\":3,\"name\":\"Programming\",\"item\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/programming\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#listItem\",\"name\":\"Git : separating folder into different repository, with history\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#listItem\",\"position\":4,\"name\":\"Git : separating folder into different repository, with history\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/category\\\/technology\\\/programming\\\/#listItem\",\"name\":\"Programming\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/#person\",\"name\":\"Leonid Mamchenkov\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3cf6df002a284d78fb6e9d8222ca4d102e0832035ed6bc8447008bd234e131a4?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Leonid Mamchenkov\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/author\\\/leonid\\\/#author\",\"url\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/author\\\/leonid\\\/\",\"name\":\"Leonid Mamchenkov\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3cf6df002a284d78fb6e9d8222ca4d102e0832035ed6bc8447008bd234e131a4?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Leonid Mamchenkov\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#webpage\",\"url\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/\",\"name\":\"Git : separating folder into different repository, with history - Leonid Mamchenkov\",\"description\":\"First things first. If you don't use git for version control yet, stop right now and go plan your migration. You'll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/2013\\\/01\\\/09\\\/git-separating-folder-into-different-repository-with-history\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/author\\\/leonid\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/author\\\/leonid\\\/#author\"},\"datePublished\":\"2013-01-09T02:26:25+02:00\",\"dateModified\":\"2013-01-09T02:26:25+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/#website\",\"url\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/\",\"name\":\"Blog of Leonid Mamchenkov\",\"description\":\"Life, universe, and everything else\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mamchenkov.net\\\/wordpress\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Git : separating folder into different repository, with history - Leonid Mamchenkov","description":"First things first. If you don't use git for version control yet, stop right now and go plan your migration. You'll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It","canonical_url":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"VHvdD0_usx1_4DzKy_QCVcICVgX2EgA2ybELT-wl7kQ","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#blogposting","name":"Git : separating folder into different repository, with history - Leonid Mamchenkov","headline":"Git : separating folder into different repository, with history","author":{"@id":"https:\/\/mamchenkov.net\/wordpress\/author\/leonid\/#author"},"publisher":{"@id":"https:\/\/mamchenkov.net\/wordpress\/#person"},"image":{"@type":"ImageObject","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#articleImage","url":"https:\/\/secure.gravatar.com\/avatar\/3cf6df002a284d78fb6e9d8222ca4d102e0832035ed6bc8447008bd234e131a4?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Leonid Mamchenkov"},"datePublished":"2013-01-09T02:26:25+02:00","dateModified":"2013-01-09T02:26:25+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#webpage"},"isPartOf":{"@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#webpage"},"articleSection":"All, Programming, Technology, git, version control"},{"@type":"BreadcrumbList","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress#listItem","position":1,"name":"Home","item":"https:\/\/mamchenkov.net\/wordpress","nextItem":{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/programming\/#listItem","name":"Programming"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/programming\/#listItem","position":3,"name":"Programming","item":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/programming\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#listItem","name":"Git : separating folder into different repository, with history"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#listItem","position":4,"name":"Git : separating folder into different repository, with history","previousItem":{"@type":"ListItem","@id":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/programming\/#listItem","name":"Programming"}}]},{"@type":"Person","@id":"https:\/\/mamchenkov.net\/wordpress\/#person","name":"Leonid Mamchenkov","image":{"@type":"ImageObject","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/3cf6df002a284d78fb6e9d8222ca4d102e0832035ed6bc8447008bd234e131a4?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Leonid Mamchenkov"}},{"@type":"Person","@id":"https:\/\/mamchenkov.net\/wordpress\/author\/leonid\/#author","url":"https:\/\/mamchenkov.net\/wordpress\/author\/leonid\/","name":"Leonid Mamchenkov","image":{"@type":"ImageObject","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/3cf6df002a284d78fb6e9d8222ca4d102e0832035ed6bc8447008bd234e131a4?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Leonid Mamchenkov"}},{"@type":"WebPage","@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#webpage","url":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/","name":"Git : separating folder into different repository, with history - Leonid Mamchenkov","description":"First things first. If you don't use git for version control yet, stop right now and go plan your migration. You'll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mamchenkov.net\/wordpress\/#website"},"breadcrumb":{"@id":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/#breadcrumblist"},"author":{"@id":"https:\/\/mamchenkov.net\/wordpress\/author\/leonid\/#author"},"creator":{"@id":"https:\/\/mamchenkov.net\/wordpress\/author\/leonid\/#author"},"datePublished":"2013-01-09T02:26:25+02:00","dateModified":"2013-01-09T02:26:25+02:00"},{"@type":"WebSite","@id":"https:\/\/mamchenkov.net\/wordpress\/#website","url":"https:\/\/mamchenkov.net\/wordpress\/","name":"Blog of Leonid Mamchenkov","description":"Life, universe, and everything else","inLanguage":"en-US","publisher":{"@id":"https:\/\/mamchenkov.net\/wordpress\/#person"}}]},"og:locale":"en_US","og:site_name":"Leonid Mamchenkov - Life, universe, and everything else","og:type":"article","og:title":"Git : separating folder into different repository, with history - Leonid Mamchenkov","og:description":"First things first. If you don't use git for version control yet, stop right now and go plan your migration. You'll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It","og:url":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/","og:image":"https:\/\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2026\/03\/leonid-sailing-beer.jpg","og:image:secure_url":"https:\/\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2026\/03\/leonid-sailing-beer.jpg","og:image:width":1024,"og:image:height":1024,"article:published_time":"2013-01-09T00:26:25+00:00","article:modified_time":"2013-01-09T00:26:25+00:00","article:publisher":"https:\/\/www.facebook.com\/MamchenkovBlog","twitter:card":"summary_large_image","twitter:site":"@mamchenkov","twitter:title":"Git : separating folder into different repository, with history - Leonid Mamchenkov","twitter:description":"First things first. If you don't use git for version control yet, stop right now and go plan your migration. You'll thank me later. Now. A few days ago I had a tricky problem. A chunk of code that was initially all over the project has been refactored into a pretty much separate library. It","twitter:creator":"@mamchenkov","twitter:image":"https:\/\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2026\/03\/leonid-sailing-beer.jpg"},"aioseo_meta_data":{"post_id":"17655","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2023-07-19 10:39:52","updated":"2026-01-15 08:29:54","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/mamchenkov.net\/wordpress\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/programming\/\" title=\"Programming\">Programming<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGit : separating folder into different repository, with history\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/mamchenkov.net\/wordpress"},{"label":"Technology","link":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/"},{"label":"Programming","link":"https:\/\/mamchenkov.net\/wordpress\/category\/technology\/programming\/"},{"label":"Git : separating folder into different repository, with history","link":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/"}],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":27374,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/27\/moving-files-with-commit-history-from-one-git-repository-to-another\/","url_meta":{"origin":17655,"position":0},"title":"Moving files with commit history from one git repository to another","author":"Leonid Mamchenkov","date":"February 27, 2017","format":false,"excerpt":"I've searched for this before, and I'm sure I'll do that again (although the need is not that frequent), so here it goes. \u00a0It is possible to move files from one git repository to another, preserving commit history. \u00a0The following links provide a few examples of how to do this:\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28607,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/06\/06\/git-worktree-a-better-way-for-git-stash-abusers\/","url_meta":{"origin":17655,"position":1},"title":"git worktree &#8211; a better way for git stash abusers","author":"Leonid Mamchenkov","date":"June 6, 2018","format":false,"excerpt":"If you constantly find yourself using \"git stash\" while working on a project, or, even worse - have multiple copies of the same project cloned on the same machine, \"git worktree\" might be a much better alternative for you. Manage multiple working trees attached to the same repository. A git\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/06\/git-500x238.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":28431,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/03\/14\/updating-wordpress-with-composer-and-wp-cli\/","url_meta":{"origin":17655,"position":2},"title":"Updating WordPress with Composer and WP-CLI","author":"Leonid Mamchenkov","date":"March 14, 2018","format":false,"excerpt":"The other day I came across this blog post by\u00a0Mark Jaquith, who is one of the lead contributors to WordPress, in which he describes his process of updating WordPress plugins with WP-CLI and Git.\u00a0 I think a lot of people these days are trying to use Git for version control\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18111,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/04\/29\/dandelion-incremental-git-repository-deployment\/","url_meta":{"origin":17655,"position":3},"title":"dandelion &#8211; Incremental Git repository deployment","author":"Leonid Mamchenkov","date":"April 29, 2013","format":"link","excerpt":"dandelion - Incremental Git repository deployment This might be really handy for those times when you need to push from Git to FTP\/SFTP or cloud services directly.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":25203,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/02\/29\/git-rebase-and-the-golden-rule-explained\/","url_meta":{"origin":17655,"position":4},"title":"Git rebase and the golden rule explained","author":"Leonid Mamchenkov","date":"February 29, 2016","format":false,"excerpt":"\"Git rebase and the golden rule explained\" - is an excellent explanation of what happens when you do rebase in git repository. \u00a0If you know already, or don't care, at least remember the golden rule: Never, NEVER, NEVER, rebase a shared branch. By shared branch I mean a branch that\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28399,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/02\/19\/grv-git-repository-viewer\/","url_meta":{"origin":17655,"position":5},"title":"GRV &#8211; Git Repository Viewer","author":"Leonid Mamchenkov","date":"February 19, 2018","format":false,"excerpt":"GRV is a text-based Git repository viewer for the console, much like tig, but with a few extra features: Commits and refs can be filtered using a query language. Changes to the repository are captured by monitoring the filesystem allowing the UI to be updated automatically. Organised as tabs and\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2018\/02\/grv-500x265.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/17655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=17655"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/17655\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=17655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=17655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=17655"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=17655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}