Guest User

Untitled

a guest
Nov 21st, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # List commits that have no changes (empty commits)
  2. git rev-list HEAD | while read commitHash; do
  3. if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then
  4. echo $commitHash
  5. fi;
  6. done
  7.  
  8. # List commits that have changes, and files changed (non empty commits):
  9.  
  10. git rev-list HEAD | while read commitHash; do
  11. git diff-tree --name-status $commitHash
  12. done
  13.  
  14. #Count empty commits
  15.  
  16. git rev-list HEAD | while read commitHash; do
  17. if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -eq 0 ]; then
  18. echo '1'
  19. fi;
  20. done | wc -l
  21.  
  22. # Count non empty commits
  23.  
  24. git rev-list HEAD | while read commitHash; do
  25. if [ $(git diff-tree --name-status --no-commit-id $commitHash | wc -l) -gt 0 ]; then
  26. echo '1'
  27. fi;
  28. done | wc -l
  29.  
  30. # remove all empty commits from the repo
  31.  
  32. git filter-branch --tag-name-filter cat --commit-filter 'git_commit_non_empty_tree "$@"' -- --all
  33.  
  34. # clean the refs
  35. git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
Add Comment
Please, Sign In to add comment