Skip to content

Instantly share code, notes, and snippets.

@WimObiwan
Last active September 13, 2017 09:49
Show Gist options
  • Save WimObiwan/84d87794c5a31cfb6954ca88ce58952a to your computer and use it in GitHub Desktop.
Save WimObiwan/84d87794c5a31cfb6954ca88ce58952a to your computer and use it in GitHub Desktop.
rm -rf ContactCentre.git/
git clone --mirror [email protected]:Askia/ContactCentre.git
cd ContactCentre.git/
git filter-branch -f --prune-empty --index-filter \
'git rm --cached -r -q -- . ; git reset -q $GIT_COMMIT -- Setups/ BuildScripts/ _Utilities/MyForceBuilder/ _MI4C\ Build\ Scripts/ ' -- --all
du . -h
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --prune=now
du . -h
# rollup all empty merges (https://stackoverflow.com/questions/9803294/prune-empty-merge-commits-from-history-in-git-repository)
git filter-branch --prune-empty --parent-filter 'sed "s/-p //g" | xargs -r git show-branch --independent | sed "s/\</-p /g"' -- --all
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire=now --all
git gc --prune=now
du . -h
# remove all tags (IF NECESSARY)
#git tag | xargs git tag -d
git remote set-url origin [email protected]:myforce/Setups.git
git remote -v
git push --mirror
cd ..
rm -rf ContactCentre.git/
@WimObiwan
Copy link
Author

Alternative, and a lot faster:
https://rtyley.github.io/bfg-repo-cleaner/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment