Imagine that you want to erase completely the file under config/secrets.yml
from your commits history
Move to the working directory where the config folder is placed
cd dummy/
Run git filter-branch
, forcing (--force
) Git to process—but not check out (--index-filter
)—the entire history of every branch and tag (--tag-name-filter cat -- --all
), removing the specified file (git rm --cached --ignore-unmatch Rakefile
) and any empty commits generated as a result (--prune-empty
). Note that you need to specify the path to the file you want to remove, not just its filename.
The previous was taken from Github documentation
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch config/secrets.yml' \
--prune-empty --tag-name-filter cat -- --all