Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # List commits that have no changes (empty commits)
- 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
- # List commits that have changes, and files changed (non empty commits):
- git rev-list HEAD | while read commitHash; do
- git diff-tree --name-status $commitHash
- done
- #Count empty commits
- git rev-list HEAD | while read commitHash; do
- if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then
- echo '1'
- fi;
- done | wc -l
- # Count non empty commits
- git rev-list HEAD | while read commitHash; do
- if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -gt 0 ]; then
- echo '1'
- fi;
- done | wc -l
- # remove all empty commits from the repo
- git filter-branch --tag-name-filter cat --commit-filter 'git_commit_non_empty_tree "$@"' -- --all
- # clean the refs
- git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
Add Comment
Please, Sign In to add comment