Skip to content

Instantly share code, notes, and snippets.

@eriksimonic
Last active December 28, 2017 11:01
Show Gist options
  • Save eriksimonic/6d4b8e625f3b09b42c5165fa0f7e5ee9 to your computer and use it in GitHub Desktop.
Save eriksimonic/6d4b8e625f3b09b42c5165fa0f7e5ee9 to your computer and use it in GitHub Desktop.
Remove Folders from Git Commits
#!/bin/sh
#Remove all folders that you need to remove.
git filter-branch -f --tree-filter "rm -fr */App_Data/*" --prune-empty --tag-name-filter cat HEAD
#Run GC cleanup of references.
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
#Force push to origin
git push origin --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment