Skip to content

Instantly share code, notes, and snippets.

@k06a k06a/erase-git.sh
Last active Mar 6, 2018

Embed
What would you like to do?
Git remove some dirs
# Fetch
git clone https://github.com/username/reponame reponame
for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done
# Analyze
curl https://bootstrap.pypa.io/get-pip.py > get-pip.py && sudo python get-pip.py && rm get-pip.py
sudo pip install git-fat
git fat -a find 1000000
git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
# Delete
git filter-branch --subdirectory-filter ios/South/ --prune-empty --tag-name-filter cat -- --all
git filter-branch --tree-filter 'rm -rf Pods' --prune-empty --tag-name-filter cat -- --all
# Migrate repo to LFS
https://github.com/github/git-lfs/issues/326
# Cleanup
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
git reflog expire --expire-unreachable=all --all
git gc --aggressive --prune=now
# LFS Install
brew update && brew install git-lfs
ln -s /usr/bin/git /usr/local/bin/git # And then in SourceTree choose the Use System Git from /usr/local/bin
# LFS usage
git lfs init
git lfs track "**/*.mp4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.