Last active
August 29, 2015 14:24
-
-
Save Iman/00ea448df37ea309ab66 to your computer and use it in GitHub Desktop.
Clean git history after file deleted from 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 | |
# remove all paths passed as arguments from the history of the repo | |
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch config/*.ini" HEAD | |
# remove the temporary history git-filter-branch otherwise leaves behind for a long time | |
rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune | |
git filter-branch -f --index-filter "git rm --cached --ignore-unmatch app/config/*.ini" --prune-empty -- --all | |
git update-index --refresh | |
#As of Git v1.7.0, you can delete a remote branch using | |
#git push origin --delete branch | |
#The above is syntactic sugar for | |
#git push origin :branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment