Created
May 8, 2015 02:00
-
-
Save chengsoonong/cabe9ed11881346330b0 to your computer and use it in GitHub Desktop.
Delete a file, and destroy its history in git.
This file contains 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 | |
# This script removes a file from the git repository and destroys all its history. | |
# | |
# Based on https://help.github.com/articles/remove-sensitive-data/ | |
# | |
# To do a dry run, add a -n to the git rm command. I.e. | |
# "git rm -n --cached --ignore-unmatch $1" | |
printf "Really destroy $1 ? y/[n] " | |
read -n 1 destroy | |
if [ "$destroy" == "y" ]; then | |
printf "\nDestroying $1\n" | |
git filter-branch --force --index-filter \ | |
"git rm -r --cached --ignore-unmatch $1" \ | |
--prune-empty --tag-name-filter cat -- --all | |
else | |
printf "\nDid not destroy $1\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment