Skip to content

Instantly share code, notes, and snippets.

@k06a
Last active May 14, 2021 03:14

Revisions

  1. k06a revised this gist Dec 14, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions erase-git.sh
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,9 @@ git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
    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
  2. k06a revised this gist Dec 10, 2015. 1 changed file with 10 additions and 3 deletions.
    13 changes: 10 additions & 3 deletions erase-git.sh
    Original file line number Diff line number Diff line change
    @@ -3,18 +3,25 @@ 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

    # Cleanup
    #git update-ref -d refs/original/refs/heads/master
    #git show-ref refs/original/* --hash | xargs -n 1 git update-ref -d
    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
    #git reflog expire --expire=now --all
    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"
  3. k06a revised this gist Dec 10, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion erase-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Fetch
    git clone https://github.com/username/reponame reponame
    for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b;
    for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done

    # Analyze
    git fat -a find 1000000
  4. k06a revised this gist Dec 10, 2015. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions erase-git.sh
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,20 @@
    # Fetch
    git clone https://github.com/username/reponame reponame
    for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b;

    # Analyze
    git fat -a find 1000000
    git ls-tree -r -t -l --full-name HEAD | sort -n -k 4

    # Delete
    #git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch dir1' HEAD
    git filter-branch --tree-filter 'rm -rf dir1' --prune-empty --tag-name-filter cat -- --all
    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

    # Cleanup
    #git update-ref -d refs/original/refs/heads/master
    #git show-ref refs/original/* --hash | xargs -n 1 git update-ref -d
    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
    #git reflog expire --expire=now --all
    git reflog expire --expire-unreachable=all --all
    git gc --aggressive --prune=now

  5. k06a revised this gist Dec 9, 2015. 2 changed files with 12 additions and 4 deletions.
    12 changes: 12 additions & 0 deletions erase-git.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # Analyze
    git ls-tree -r -t -l --full-name HEAD | sort -n -k 4

    # Delete
    #git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch dir1' HEAD
    git filter-branch --tree-filter 'rm -rf dir1' --prune-empty --tag-name-filter cat -- --all

    # Cleanup
    #git update-ref -d refs/original/refs/heads/master
    #git show-ref refs/original/* --hash | xargs -n 1 git update-ref -d
    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

    4 changes: 0 additions & 4 deletions remove.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +0,0 @@
    git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
    git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch dir1' HEAD
    git update-ref -d refs/original/refs/heads/master
    git show-ref refs/original/* --hash | xargs -n 1 git update-ref -d
  6. k06a revised this gist Dec 9, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion remove.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
    git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch dir1' HEAD
    git update-ref -d refs/original/refs/heads/master
    git update-ref -d refs/original/refs/heads/master
    git show-ref refs/original/* --hash | xargs -n 1 git update-ref -d
  7. k06a created this gist Dec 9, 2015.
    3 changes: 3 additions & 0 deletions remove.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
    git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch dir1' HEAD
    git update-ref -d refs/original/refs/heads/master