{"id":17993,"date":"2017-05-15T14:55:52","date_gmt":"2017-05-15T18:55:52","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=17993"},"modified":"2017-05-15T14:55:52","modified_gmt":"2017-05-15T18:55:52","slug":"a-tale-of-three-git-filter-branches","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/05\/15\/a-tale-of-three-git-filter-branches\/","title":{"rendered":"A Tale of Three Git Filter Branches"},"content":{"rendered":"<p><a href=\"https:\/\/wincent.com\/blog\/filter-branch\">Greg Hurrell<\/a> (via <a href=\"https:\/\/twitter.com\/wincent\/status\/863640786381922305\">tweet<\/a>):<\/p>\n<blockquote cite=\"https:\/\/wincent.com\/blog\/filter-branch\"><p>I used <code>git-filter-branch<\/code> to rewrite the history of the repo containing this website&rsquo;s files, processing 4,980 commits and transforming 3,702 wikitext files to Markdown along the way. I wrote three separate versions: the first would have taken as long as 42 days to complete, the second perhaps 3 to 4 days, and the third and final version completed in about an hour.<\/p><p>[&#8230;]<\/p><p>That last one sure sounds the most elegant, doesn&rsquo;t it? But it also obliges us to accept a reality about Git&rsquo;s object database: it&rsquo;s made to be blazingly fast for certain common operations (<code>git status<\/code>, <code>git commit<\/code> etc) but not others. For example, answering that question of &ldquo;detecting when an item first entered the repository&rdquo; could require you to traverse back from the current <code>HEAD<\/code> all the way back to the root commit of the repository, which could mean examining a thousands-long commit chain. And note, even if you know how Git works and seek to minimize the number of <code>git<\/code> processes that you need fork and the number of commits that you actually need to examine (eg. by limiting <code>git log<\/code> with a pathspec), Git&rsquo;s internals will still need to traverse that thousands-long chain in the worst case.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Greg Hurrell (via tweet): I used git-filter-branch to rewrite the history of the repo containing this website&rsquo;s files, processing 4,980 commits and transforming 3,702 wikitext files to Markdown along the way. I wrote three separate versions: the first would have taken as long as 42 days to complete, the second perhaps 3 to 4 days, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[377,138,71],"class_list":["post-17993","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-git","tag-optimization","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=17993"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17993\/revisions"}],"predecessor-version":[{"id":17994,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17993\/revisions\/17994"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}