Last Updated: October 12, 2018
· emadb

Permanently remove files from git repo

If you accidentally pushed some files to the git repos and you want to permanently delete them (so that you can reduce the repo size) you can use this command:

git filter-branch --tree-filter 'rm -rf my_folder/my_file' HEAD

1 Response
Add your response

It's worth noting that it rewrites your entire history (from when the file was created), so it doesn't work well with a shared repo unless you can force everybody to throw away their local copy and clone a fresh copy.

over 1 year ago ·