{"id":27374,"date":"2017-02-27T11:26:07","date_gmt":"2017-02-27T09:26:07","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=27374"},"modified":"2017-02-27T11:26:07","modified_gmt":"2017-02-27T09:26:07","slug":"moving-files-with-commit-history-from-one-git-repository-to-another","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/27\/moving-files-with-commit-history-from-one-git-repository-to-another\/","title":{"rendered":"Moving files with commit history from one git repository to another"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I&#8217;ve searched for this before, and I&#8217;m sure I&#8217;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:<\/p>\n<ul>\n<li>Greg Bayer&#8217;s <a href=\"http:\/\/gbayer.com\/development\/moving-files-from-one-git-repository-to-another-preserving-history\/\">explanation<\/a><\/li>\n<li>StackOverflow <a href=\"http:\/\/stackoverflow.com\/questions\/1365541\/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history\">discussion<\/a><\/li>\n<li>Another StackOverflow <a href=\"http:\/\/stackoverflow.com\/questions\/10524578\/how-to-move-a-file-from-one-git-repository-to-another-while-preserving-history\">discussion<\/a><\/li>\n<\/ul>\n<p>Basically, you need <a href=\"https:\/\/git-scm.com\/docs\/git-filter-branch\"><em>git filter-branch<\/em><\/a> command, usually with the <a href=\"https:\/\/git-scm.com\/docs\/git-filter-branch#git-filter-branch---subdirectory-filterltdirectorygt\"><em>&#8211;subdirectory-filter<\/em><\/a> parameter.<\/p>\n<p>An example of where it is useful would be the extraction of some code from a project you have into a shared library or a simple plugin.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I&#8217;ve searched for this before, and I&#8217;m sure I&#8217;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: Greg Bayer&#8217;s explanation StackOverflow discussion &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/27\/moving-files-with-commit-history-from-one-git-repository-to-another\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Moving files with commit history from one git repository to another<\/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_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Moving files with commit history from one git repository to another #git #WebDev #programming","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},"_links_to":"","_links_to_target":""},"categories":[1,18,62,1334],"tags":[2265,1588,1330],"keyring_services":[],"class_list":["post-27374","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-git","tag-version-control","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":17655,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/","url_meta":{"origin":27374,"position":0},"title":"Git : separating folder into different repository, with history","author":"Leonid Mamchenkov","date":"January 9, 2013","format":false,"excerpt":"First things first. \u00a0If you don't use git for version control yet, stop right now and go plan your migration. \u00a0You'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\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":26685,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/09\/12\/git-history-of-a-source-code-line\/","url_meta":{"origin":27374,"position":1},"title":"git: history of a source code line","author":"Leonid Mamchenkov","date":"September 12, 2016","format":false,"excerpt":"git is one of those tools that no matter how much you know about it, there is an infinite supply of new things to learn. \u00a0Here's a handy bit I've discovered recently, thanks to this StackOverflow comment: Since Git 1.8.4, git log has -L to view the evolution of a\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":27671,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/06\/08\/git-commit-good-practice\/","url_meta":{"origin":27374,"position":2},"title":"Git Commit Good Practice","author":"Leonid Mamchenkov","date":"June 8, 2017","format":false,"excerpt":"Open Stack wiki has an excellent guide on how to create good commits. \u00a0In a few places it is too specific to Open Stack development practices, but overall it's one of the best guides I've seen for any project using git. It is basically split into two sections. \u00a0One on\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\/2017\/06\/git_commit.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":23822,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/04\/07\/10-years-of-git-an-interview-with-git-creator-linus-torvalds\/","url_meta":{"origin":27374,"position":3},"title":"10 Years of Git: An Interview with Git Creator Linus Torvalds","author":"Leonid Mamchenkov","date":"April 7, 2015","format":false,"excerpt":"Linux.com reminds us that git is celebrating its 10th birthday this year. \u00a0An interview with git creator Linus Torvalds sheds some light on to how and why it happened, and how long it took. You can actually see how it all took shape in the git source code repository, except\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"AtlassianGit10year","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2015\/04\/AtlassianGit10year-500x295.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":24691,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/09\/01\/gitfs-version-controlled-file-system\/","url_meta":{"origin":27374,"position":4},"title":"gitfs &#8211; version controlled file system","author":"Leonid Mamchenkov","date":"September 1, 2015","format":false,"excerpt":"This was only a matter of time ... gitfs\u00a0- version controlled file system: gitfs was designed to bring the full powers of git to everyone, no matter how little they know about versioning. A user can mount any repository and all the his changes will be automatically converted into commits.\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":22166,"url":"https:\/\/mamchenkov.net\/wordpress\/2014\/07\/10\/git-branch-names-support-forward-slashes\/","url_meta":{"origin":27374,"position":5},"title":"Git branch names support forward slashes","author":"Leonid Mamchenkov","date":"July 10, 2014","format":false,"excerpt":"Oh. My. God! \u00a0I've been using git for years now and I only learned this today - git branch names support forward slashes! How awesome is that?! \u00a0You can do things like this: Grouping branches like this is much easier indeed! I came across this while reading CakeDC's CakePHP Plugin\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":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27374","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=27374"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27374\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=27374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=27374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=27374"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=27374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}