Skip to content

Instantly share code, notes, and snippets.

@npyoung
Created July 20, 2016 19:32
Show Gist options
  • Save npyoung/259cd23947acac5d93a7eceb1acab98b to your computer and use it in GitHub Desktop.
Save npyoung/259cd23947acac5d93a7eceb1acab98b to your computer and use it in GitHub Desktop.
The git-filter method of removing a file completely from git history. Remember to `git push --force` if the repo has a remote!
#!/usr/bin/env bash
FILEPATH=$@
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch $FILEPATH" --prune-empty --tag-name-filter cat -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment