Skip to content

Instantly share code, notes, and snippets.

@scsskid
Created January 29, 2021 20:35
Show Gist options
  • Save scsskid/9156d63a58a87fec09319d8360235f4a to your computer and use it in GitHub Desktop.
Save scsskid/9156d63a58a87fec09319d8360235f4a to your computer and use it in GitHub Desktop.
[git remove from history] #bash #git
# src: https://stackoverflow.com/a/17824718/2823589
git filter-branch --tree-filter "rm -rf node_modules" --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
echo node_modules/ >> .gitignore
git add .gitignore
git commit -m 'Removing node_modules from git history'
git gc
git push origin master --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment