Skip to content

Instantly share code, notes, and snippets.

@QNimbus
Created March 30, 2019 10:18
Show Gist options
  • Save QNimbus/2c1d029137bce325ef493f9f62d64435 to your computer and use it in GitHub Desktop.
Save QNimbus/2c1d029137bce325ef493f9f62d64435 to your computer and use it in GitHub Desktop.
Delete a file/folder from your entire git history
git filter-branch --tree-filter 'rm -rf dist' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
cat <<EOT > .gitignore
node_modules/
dist/
EOT
git add .gitignore
git commit -m 'Removing dist from git history'
git gc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment