Created
August 26, 2020 18:32
Revisions
-
filipechagas created this gist
Aug 26, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # Git filter-branch So today I noticed my git repository was taking too much disk space and discovered it was due to bundler caching gems. At first I thought I'd just remove `vendor/cache` directory it be done with it. But that's not how git works, is it? That's how I came across `git filter-branch`. The following command will remove the `vendor/cache` directory and all its references throughout your repository history. `git filter-branch --force --index-filter "git rm --cached --ignore-unmatch -r vendor/cache"` ## Undoing it And, should you realise you shouldn't have done that, git is also there for you. Whenever you use `filter-branch`, git creates a backup of the previous state for you at `.git/refs/original/refs/heads/NAME_OF_YOUR_BRANCH`. Meaning all you have to do is run: `git reset --hard refs/original/refs/heads/NAME_OF_YOUR_BRANCH` You're welcome ;)