{"id":690,"date":"2014-04-08T11:00:46","date_gmt":"2014-04-08T15:00:46","guid":{"rendered":"https:\/\/reviewsignal.com\/blog\/?p=690"},"modified":"2014-04-06T04:21:59","modified_gmt":"2014-04-06T08:21:59","slug":"how-to-remove-files-from-git-repo-permanently","status":"publish","type":"post","link":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/","title":{"rendered":"How To Remove Files from Git Repo Permanently"},"content":{"rendered":"<p>I ran into this issue in the past week. My .PACK file was enormous (many many gigabytes) because I committed a lot of files I shouldn't have in the past. Large binary files, backups and other things that don't belong in a Git repo.<\/p>\n<p>I deleted the files and committed those, but Git is really good at making sure you never lose data. So despite having a small repo, I had a .PACK file that was 10 times the size of the repo.<\/p>\n<p>I googled around a lot and the best post I could find on StackOverflow was <a href=\"http:\/\/stackoverflow.com\/questions\/5563564\/completely-remove-files-from-git-repo-and-remote-on-github\">completely remove files from git repo and github on remote<\/a>. It didn't quite work for me though.<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\"><span style=\"color: #c20cb9; font-weight: bold;\">git filter-branch<\/span> <span style=\"color: #660033;\">-f<\/span> <span style=\"color: #660033;\">--index-filter<\/span> <span style=\"color: #ff0000;\">'git rm -r --cached --ignore-unmatch &quot;filename&quot;'<\/span> <span style=\"color: #660033;\">--prune-empty<\/span> HEAD\n<span style=\"color: #c20cb9; font-weight: bold;\">rm<\/span> <span style=\"color: #660033;\">-rf<\/span> .git<span style=\"color: #000000; font-weight: bold;\">\/<\/span>refs<span style=\"color: #000000; font-weight: bold;\">\/<\/span>original<span style=\"color: #000000; font-weight: bold;\">\/<\/span> <span style=\"color: #000000; font-weight: bold;\">&amp;&amp;<\/span> <span style=\"color: #c20cb9; font-weight: bold;\">git reflog<\/span> expire <span style=\"color: #660033;\">--expire<\/span>=now <span style=\"color: #660033;\">--all<\/span> <span style=\"color: #000000; font-weight: bold;\">&amp;&amp;<\/span> <span style=\"color: #c20cb9; font-weight: bold;\">git gc<\/span> <span style=\"color: #660033;\">--aggressive<\/span> <span style=\"color: #660033;\">--prune<\/span>=now<\/pre><\/td><\/tr><\/table><\/div>\n\n<p>I just had to add a few flags to get this working.<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\"><span style=\"color: #660033;\">-f<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p> and<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\"><span style=\"color: #660033;\">--prune-empty<\/span><\/pre><\/td><\/tr><\/table><\/div>\n\n<p> in the git filter-branch.<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\"><span style=\"color: #660033;\">--expire<\/span>=now<\/pre><\/td><\/tr><\/table><\/div>\n\n<p> and<\/p>\n\n<div class=\"wp_syntax\"><table><tr><td class=\"code\"><pre class=\"bash\" style=\"font-family:monospace;\"><span style=\"color: #660033;\">--prune<\/span>=now<\/pre><\/td><\/tr><\/table><\/div>\n\n<p> in the second line of commands.<\/p>\n<p>Now you can run those two commands (replacing filename with a file name or directory) and it should permanently remove the file from the repo including the PACK file. <\/p>\n<p>Be very careful when you run this command, I am not sure there is a way to undo this change.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I ran into this issue in the past week. My .PACK file was enormous (many many gigabytes) because I committed a lot of files I shouldn&#8217;t have in the past. Large binary files, backups and other things that don&#8217;t belong in a Git repo. I deleted the files and committed those, but Git is really [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-690","post","type-post","status-publish","format-standard","hentry","category-how-tuesday"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Kevin Ohashi\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Review Signal Blog\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How To Remove Files from Git Repo Permanently | Review Signal Blog\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-04-08T15:00:46+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2014-04-06T08:21:59+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How To Remove Files from Git Repo Permanently | Review Signal Blog\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#article\",\"name\":\"How To Remove Files from Git Repo Permanently | Review Signal Blog\",\"headline\":\"How To Remove Files from Git Repo Permanently\",\"author\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/author\\\/kohashi\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-04-08T11:00:46-04:00\",\"dateModified\":\"2014-04-06T04:21:59-04:00\",\"inLanguage\":\"en-US\",\"commentCount\":1,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#webpage\"},\"articleSection\":\"How-Tuesday\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/category\\\/how-tuesday\\\/#listItem\",\"name\":\"How-Tuesday\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/category\\\/how-tuesday\\\/#listItem\",\"position\":2,\"name\":\"How-Tuesday\",\"item\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/category\\\/how-tuesday\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#listItem\",\"name\":\"How To Remove Files from Git Repo Permanently\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#listItem\",\"position\":3,\"name\":\"How To Remove Files from Git Repo Permanently\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/category\\\/how-tuesday\\\/#listItem\",\"name\":\"How-Tuesday\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#organization\",\"name\":\"Review Signal Blog\",\"url\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/author\\\/kohashi\\\/#author\",\"url\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/author\\\/kohashi\\\/\",\"name\":\"Kevin Ohashi\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a62947400dd8e40200dee3dc620c62f8a9770e88a4e1185fd17bbcbf624525a6?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Kevin Ohashi\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#webpage\",\"url\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/\",\"name\":\"How To Remove Files from Git Repo Permanently | Review Signal Blog\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/2014\\\/04\\\/08\\\/how-to-remove-files-from-git-repo-permanently\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/author\\\/kohashi\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/author\\\/kohashi\\\/#author\"},\"datePublished\":\"2014-04-08T11:00:46-04:00\",\"dateModified\":\"2014-04-06T04:21:59-04:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/\",\"name\":\"Review Signal Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/reviewsignal.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How To Remove Files from Git Repo Permanently | Review Signal Blog","description":"","canonical_url":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#article","name":"How To Remove Files from Git Repo Permanently | Review Signal Blog","headline":"How To Remove Files from Git Repo Permanently","author":{"@id":"https:\/\/reviewsignal.com\/blog\/author\/kohashi\/#author"},"publisher":{"@id":"https:\/\/reviewsignal.com\/blog\/#organization"},"datePublished":"2014-04-08T11:00:46-04:00","dateModified":"2014-04-06T04:21:59-04:00","inLanguage":"en-US","commentCount":1,"mainEntityOfPage":{"@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#webpage"},"isPartOf":{"@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#webpage"},"articleSection":"How-Tuesday"},{"@type":"BreadcrumbList","@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/reviewsignal.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/category\/how-tuesday\/#listItem","name":"How-Tuesday"}},{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/category\/how-tuesday\/#listItem","position":2,"name":"How-Tuesday","item":"https:\/\/reviewsignal.com\/blog\/category\/how-tuesday\/","nextItem":{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#listItem","name":"How To Remove Files from Git Repo Permanently"},"previousItem":{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#listItem","position":3,"name":"How To Remove Files from Git Repo Permanently","previousItem":{"@type":"ListItem","@id":"https:\/\/reviewsignal.com\/blog\/category\/how-tuesday\/#listItem","name":"How-Tuesday"}}]},{"@type":"Organization","@id":"https:\/\/reviewsignal.com\/blog\/#organization","name":"Review Signal Blog","url":"https:\/\/reviewsignal.com\/blog\/"},{"@type":"Person","@id":"https:\/\/reviewsignal.com\/blog\/author\/kohashi\/#author","url":"https:\/\/reviewsignal.com\/blog\/author\/kohashi\/","name":"Kevin Ohashi","image":{"@type":"ImageObject","@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a62947400dd8e40200dee3dc620c62f8a9770e88a4e1185fd17bbcbf624525a6?s=96&d=mm&r=g","width":96,"height":96,"caption":"Kevin Ohashi"}},{"@type":"WebPage","@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#webpage","url":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/","name":"How To Remove Files from Git Repo Permanently | Review Signal Blog","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/reviewsignal.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/#breadcrumblist"},"author":{"@id":"https:\/\/reviewsignal.com\/blog\/author\/kohashi\/#author"},"creator":{"@id":"https:\/\/reviewsignal.com\/blog\/author\/kohashi\/#author"},"datePublished":"2014-04-08T11:00:46-04:00","dateModified":"2014-04-06T04:21:59-04:00"},{"@type":"WebSite","@id":"https:\/\/reviewsignal.com\/blog\/#website","url":"https:\/\/reviewsignal.com\/blog\/","name":"Review Signal Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/reviewsignal.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Review Signal Blog","og:type":"article","og:title":"How To Remove Files from Git Repo Permanently | Review Signal Blog","og:url":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/","article:published_time":"2014-04-08T15:00:46+00:00","article:modified_time":"2014-04-06T08:21:59+00:00","twitter:card":"summary","twitter:title":"How To Remove Files from Git Repo Permanently | Review Signal Blog"},"aioseo_meta_data":{"post_id":"690","title":null,"description":null,"keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":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_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"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,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 20:31:25","updated":"2026-11-03 20:31:25"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/reviewsignal.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/reviewsignal.com\/blog\/category\/how-tuesday\/\" title=\"How-Tuesday\">How-Tuesday<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow To Remove Files from Git Repo Permanently\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/reviewsignal.com\/blog\/"},{"label":"How-Tuesday","link":"https:\/\/reviewsignal.com\/blog\/category\/how-tuesday\/"},{"label":"How To Remove Files from Git Repo Permanently","link":"https:\/\/reviewsignal.com\/blog\/2014\/04\/08\/how-to-remove-files-from-git-repo-permanently\/"}],"_links":{"self":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/comments?post=690"}],"version-history":[{"count":7,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":697,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/posts\/690\/revisions\/697"}],"wp:attachment":[{"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/media?parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/categories?post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reviewsignal.com\/blog\/wp-json\/wp\/v2\/tags?post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}