Skip to content

Instantly share code, notes, and snippets.

@katmutua
Created July 8, 2016 09:47
Show Gist options
  • Select an option

  • Save katmutua/5f3cab776b9e1e50a0439db5a0d35960 to your computer and use it in GitHub Desktop.

Select an option

Save katmutua/5f3cab776b9e1e50a0439db5a0d35960 to your computer and use it in GitHub Desktop.
Remove folder from git history
//Eg. remove node modules 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