Created
March 7, 2018 14:36
-
-
Save dennyweiss/e4e50d74bd3aac971c6559a109c4ece3 to your computer and use it in GitHub Desktop.
Remove directory from git history
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
# unashamed copied from https://stackoverflow.com/a/17824718 | |
RELATIVE_DIRECTORY="node_modules" | |
git filter-branch --tree-filter "rm -rf ${RELATIVE_DIRECTORY}" --prune-empty HEAD | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
echo "${RELATIVE_DIRECTORY}/ >> .gitignore | |
git add .gitignore | |
git commit -m "Removing ${RELATIVE_DIRECTORY} from git history" | |
git gc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment