From 370e33c9bae76aadfd0b876b75275c7665e5a4da Mon Sep 17 00:00:00 2001 From: lelgenio Date: Fri, 23 Oct 2020 02:21:18 -0300 Subject: [PATCH] add and use git cleaning scripts --- dotfiles/scripts/_git-list-fat | 13 +++++++++++++ dotfiles/scripts/_git-rm-fat | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 dotfiles/scripts/_git-list-fat create mode 100644 dotfiles/scripts/_git-rm-fat diff --git a/dotfiles/scripts/_git-list-fat b/dotfiles/scripts/_git-list-fat new file mode 100644 index 0000000..e736848 --- /dev/null +++ b/dotfiles/scripts/_git-list-fat @@ -0,0 +1,13 @@ +#!/bin/sh + +git rev-list --all --objects | \ + sed -n $(git rev-list --objects --all | \ + cut -f1 -d' ' | \ + git cat-file --batch-check | \ + grep blob | \ + sort -n -k 3 | \ + tail -n40 | \ + while read hash type size; do + echo -n "-e s/$hash/$size/p "; + done) | \ + sort -n -k1 diff --git a/dotfiles/scripts/_git-rm-fat b/dotfiles/scripts/_git-rm-fat new file mode 100644 index 0000000..6e940fc --- /dev/null +++ b/dotfiles/scripts/_git-rm-fat @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +read files + +git filter-branch -f --index-filter \ + "git rm --force --cached --ignore-unmatch $files" \ + -- --all + +rm -Rf .git/refs/original && \ + git reflog expire --expire=now --all && \ + git gc --aggressive && \ + git prune