Skip to content

Instantly share code, notes, and snippets.

@MonrealRyan
Last active July 24, 2020 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MonrealRyan/596800f406cb5feae794f9a6471e0d55 to your computer and use it in GitHub Desktop.
Save MonrealRyan/596800f406cb5feae794f9a6471e0d55 to your computer and use it in GitHub Desktop.
Remove folder and its contents from git history
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