Skip to content

Instantly share code, notes, and snippets.

@zielmicha
Created May 13, 2015 17:19
Show Gist options
  • Save zielmicha/dde3c004adcb3eb1484e to your computer and use it in GitHub Desktop.
Save zielmicha/dde3c004adcb3eb1484e to your computer and use it in GitHub Desktop.
Remove files not matching regular exception from repo history. Useful for splitting repos.
#!/bin/bash
set -e
FOUND="$(find -type f | grep -v '\.git/' | grep -v dart || true)"
if [ "$FOUND" != "" ]; then
git rm -f --ignore-unmatch $FOUND
fi
# clean submodules
find -type d -exec 'git' 'rm' '{}' ';' 2>/dev/null || true
git filter-branch -f --prune-empty -d /dev/shm/scratch \
--tree-filter $PWD/cleangit.sh \
--tag-name-filter cat -- --all #>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment