Skip to content

Instantly share code, notes, and snippets.

@Jamim
Created October 19, 2019 22:55
Show Gist options
  • Save Jamim/dc2b6ed041b13d6d8305388768186dbc to your computer and use it in GitHub Desktop.
Save Jamim/dc2b6ed041b13d6d8305388768186dbc to your computer and use it in GitHub Desktop.
Clean up the twint repository
#!/bin/bash
# !!! WARNING !!!
# Before you execute this script you should backup your repository.
# https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_the_nuclear_option_filter_branch
git filter-branch --prune-empty --tree-filter 'rm -rf graph/node_modules' -- --all
# https://stackoverflow.com/questions/7654822/remove-refs-original-heads-master-from-git-repo-after-filter-branch-tree-filte
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --aggressive --prune=now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment