{"id":7645,"date":"2018-06-25T00:06:48","date_gmt":"2018-06-24T16:06:48","guid":{"rendered":"http:\/\/rmohan.com\/?p=7645"},"modified":"2018-06-25T00:06:48","modified_gmt":"2018-06-24T16:06:48","slug":"how-remove-files-completely-from-git-repository-history","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7645","title":{"rendered":"How Remove Files completely from git repository history"},"content":{"rendered":"<p id=\"e8c3\" class=\"graf graf--p graf-after--figure\">It is straight forward to remove a file from the current commit or HEAD but if you want remove entirely from the repository\u2019s history then you need to run couple of commands.<\/p>\n<p id=\"e59c\" class=\"graf graf--p graf-after--p\">It took some trial and error for me to find something that worked for me<\/p>\n<ul class=\"postList\">\n<li id=\"9000\" class=\"graf graf--li graf-after--p\"><strong class=\"markup--strong markup--li-strong\">Find out the path fo the file in your repo<\/strong><\/li>\n<li id=\"059a\" class=\"graf graf--li graf-after--li\"><strong class=\"markup--strong markup--li-strong\">Execute Below command with file path<\/strong><\/li>\n<\/ul>\n<pre id=\"b803\" class=\"graf graf--pre graf-after--li\">git filter-branch --index-filter \"git rm -rf --cached --ignore-unmatch path_to_file\" HEAD<\/pre>\n<blockquote id=\"9f7a\" class=\"graf graf--blockquote graf-after--pre\"><p>It\u2019s a time intensive task might takes good amount of time to complete. As it has to check each commit and remove. For my repo which is ~10 years old took almost 10hours with 90K commits.<\/p><\/blockquote>\n<ul class=\"postList\">\n<li id=\"5d9d\" class=\"graf graf--li graf-after--blockquote\"><strong class=\"markup--strong markup--li-strong\">If you want to push it to remote repo just do git push<\/strong><\/li>\n<\/ul>\n<pre id=\"daa9\" class=\"graf graf--pre graf-after--li\">git push -all<\/pre>\n<p id=\"b11a\" class=\"graf graf--p graf-after--pre graf--trailing\">If you like it and want to spread this please clap it as mush as possible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p id=\"e8c3\" class=\"graf graf--p graf-after--figure\">It is straight forward to remove a file from the current commit or HEAD but if you want remove entirely from the repository\u2019s history then you need to run couple of commands.<\/p>\n<p id=\"e59c\" class=\"graf graf--p graf-after--p\">It took some trial and error for me to find something that worked for me<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[96],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7645"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7645"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7645\/revisions"}],"predecessor-version":[{"id":7646,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7645\/revisions\/7646"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}