Git

To remove a file from the repository’s commit history

This approach will rerun the whole commit history and removes all tags in the process.  The end result is a clean repository with all the commits.

$ git filter-branch --index-filter 'git update-index --remove BadFile' master

To push the changes back to the remote repo:

$ git push origin master --force

Clean up and reclaim the space:

$ rm -rf .git/refs/original/
$ git reflog expire --all
$ git gc --aggressive --prune

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.