Git - remove commits with empty changeset using filter-branch
Solution 1:
Just add on the --prune-empty
option:
git filter-branch --tree-filter 'rm -rf my_folder' --prune-empty -f HEAD
(And of course, if you have other refs, you might want to rewrite everything with -- --all
instead of just HEAD
.)
Note that this isn't compatible with --commit-filter
; in that case, Charles Bailey has your answer.
Solution 2:
Just looking a the documentation for filter-branch
, you should be able to do this:
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' HEAD