Created
October 29, 2022 11:44
-
-
Save dginhoux/ca002d95a641d94e26545351f5e665b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# git rev-list HEAD | while read commitHash; do | |
# if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then | |
# echo $commitHash | |
# fi; | |
# done | |
export FILTER_BRANCH_SQUELCH_WARNING=1 | |
export folder=$1 | |
git -C $folder filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' -f HEAD | |
rm -rf $folder/.git/refs/original/ && git -C $folder reflog expire --all && git -C $folder gc --aggressive --prune | |
git -C $folder rm -r --cached . | |
git -C $folder add . | |
git -C $folder commit -m "purge empty commit" | |
git -C $folder push gitea --force | |
git -C $folder push github --force | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment