{"id":2375,"date":"2015-11-29T23:05:15","date_gmt":"2015-11-29T23:05:15","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=2375"},"modified":"2015-12-03T07:37:19","modified_gmt":"2015-12-03T07:37:19","slug":"remove-large-dead-files-from-git-repo","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=2375","title":{"rendered":"Remove large dead files from Git Repo"},"content":{"rendered":"<p>The issue is that, even though you removed the files, they are still present in previous revisions. That&#8217;s the whole point of git, is that even if you delete something, you can still get it back by accessing the history.<\/p>\n<p>What you are looking to do is called rewriting history, and it involved the\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">git filter-branch<\/div><\/div>\n<p>command.<\/p>\n<p>GitHub has a good explanation of the issue on their site.\u00a0<a href=\"https:\/\/help.github.com\/articles\/remove-sensitive-data\">https:\/\/help.github.com\/articles\/remove-sensitive-data<\/a><\/p>\n<p>To answer your question more directly, what you basically need to run is this:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch unwanted_folder' --prune-empty<\/div><\/div>\n<p>This will remove all references to the files from the history of the repo.<\/p>\n<p>Next, you&#8217;ll want to run this, to actually remove the files from the packfile.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">git gc --aggressive --prune<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The issue is that, even though you removed the files, they are still present in previous revisions. That&#8217;s the whole point of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2375","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2375"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2375\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}