git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git filter branch - removing empty commits

From
Peter Waller <peter.waller@gmail.com>
Date
Oct 6, 2008, 14:57 UTC
Message-ID
<19839587.post@talk.nabble.com>
Dear List,

I have removed lots of files from my history with a procedure something like this:

1) Clone repository
2) git filter-branch --index-filter 'git rm --quiet -r Archive; git ls-files
-z '\''*.png'\'' '\''*.eps'\'' | xargs -0r git rm --quiet; true'
3) git reflog expire --expire=0 --all
4) git prune; git gc
The problem is that this leaves many empty commits.
The helpful people over at #git advised I do:

git filter-branch --commit-filter 'if [ z$1 = z`git rev-parse $3^{tree} 2> /dev/null` ]; then skip_commit "$@"; else git commit-tree "$@"; fi'

But this gets to about commit 70/1300 and grinds to a halt. I modified /usr/libexec/git-core/git-filter-branch to say #!/bin/sh -x, and the result was over 80mb in a few seconds.

I have pasted the last few lines here: http://rafb.net/p/ABWvCy44.html

It is like it is following some exponential behaviour and not getting anywhere.

Any ideas what is wrong?

I have tried a couple of scripts I have found around that should do the same thing, for example:

skip_commit()
{
        shift
        while [[ -n $1 ]] ; do
                shift
                map "$1"
                shift
        done
}

our_tree="$1" our_parent_tree=$(map $3)

if [[ ${our_tree} == $(git rev-parse $(map $3)) ]]; then
        git commit-tree "$@"
else
        skip_commit "$@"
fi

This goes much faster, but when it reaches the final commit, it says this: Ref 'refs/heads/master' was deleted fatal: Not a valid object name HEAD

And not much useful seems to have happened.
Any help appreciated.
Regards,
- Peter
-- 
View this message in context: http://www.nabble.com/Git-filter-branch---removing-empty-commits-tp19839587p19839587.html
Sent from the git mailing list archive at Nabble.com.
Message 1 of 1 in “Git filter branch - removing empty commits”
  1. Peter WallerOct 6, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.