Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active July 12, 2017 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vielhuber/6ab7686fc508ce87c52b10bb5d01ee51 to your computer and use it in GitHub Desktop.
Save vielhuber/6ab7686fc508ce87c52b10bb5d01ee51 to your computer and use it in GitHub Desktop.
Bitbucket: Remove folder from history
mkdir testrepo && cd testrepo
git clone git@bitbucket.org:vielhuber/testrepo.git .
mkdir foo && cd foo
seq -w 1 900 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=1024 count=1024'
cd .. && mkdir bar && cd bar
seq -w 1 900 | xargs -n1 -I% sh -c 'dd if=/dev/urandom of=file.% bs=1024 count=1024'
cd ..
git add -A . && git commit -m "initial push with some data" && git push origin master
git count-objects -vH
echo /foo/ >> .gitignore
git rm -rf --cached foo/
git add -A .
git commit -m "removed /foo/ from git history"
git push origin master
cd ..
wget http://repo1.maven.org/maven2/com/madgag/bfg/1.12.15/bfg-1.12.15.jar
mkdir testrepo-clean
git clone --mirror git@bitbucket.org:vielhuber/testrepo.git testrepo-clean
java -jar bfg-1.12.15.jar --delete-folders foo testrepo-clean
cd testrepo-clean
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
cd ..
rm -rf testrepo-clean.bfg-report
rm bfg-1.12.15.jar
cd testrepo-clean
git count-objects -vH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment