From: Petr Baudis Date: Thu, 30 Oct 2008 00:33:53 GMT Subject: [PATCH] git-filter-branch: Add an example on how to remove empty commits Message-ID: <1225326833-15210-1-git-send-email-pasky@suse.cz> From: Sverre Rabbelier Signed-off-by: Sverre Rabbelier Signed-off-by: Petr Baudis --- Documentation/git-filter-branch.txt | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt index fed6de6..2565244 100644 --- a/Documentation/git-filter-branch.txt +++ b/Documentation/git-filter-branch.txt @@ -246,6 +246,21 @@ git filter-branch --commit-filter ' fi' HEAD ------------------------------------------------------------------------------ +To remove commits that are empty (do not introduce any change): + +------------------------------------------------------------------------------ +git rev-list HEAD | while read c; do [ -n "$(git diff-tree --root $c)" ] || echo $c; done > revs + +git filter-branch --commit-filter ' + if grep -q "$GIT_COMMIT" '"$(pwd)/"revs'; + then + skip_commit "$@"; + else + git commit-tree "$@"; + fi' HEAD + +------------------------------------------------------------------------------ + The function 'skip_commit' is defined as follows: -------------------------- -- 1.5.6.3.536.g61aad