Skip to content

Instantly share code, notes, and snippets.

@darkmavis1980
Created May 23, 2018 11:41
Show Gist options
  • Save darkmavis1980/066bee85b436870e91cf925bf934cdd7 to your computer and use it in GitHub Desktop.
Save darkmavis1980/066bee85b436870e91cf925bf934cdd7 to your computer and use it in GitHub Desktop.
Remove node_modules folder from git
# Found it here: https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history
# Saved this gist as some people really don't understand that you don't have to put node_modules in your bloody repository
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