Last active
August 29, 2015 14:11
-
-
Save edwardsmatt/cce80da862ac10e1dc4f to your computer and use it in GitHub Desktop.
Remove file from git history and tags.
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 characters
Based on this -https://gist.github.com/shennyg/1047737- modified to use the instructions from: https://help.github.com/articles/remove-sensitive-data/ | |
* This will overwrite your existing tags. |
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 characters
#!/bin/bash | |
set -o errexit | |
if [ $# -eq 0 ]; then | |
exit 0 | |
fi | |
if [ ! -d .git ]; then | |
echo "Error: please go to the root of the git repository and try running this again" | |
exit 1 | |
fi | |
files=$@ | |
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch $files" --prune-empty --tag-name-filter cat -- --all | |
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin && git reflog expire --expire=now --all && git gc --aggressive --prune=now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment