{"thread":{"id":"15800","subject":"Git filter branch - removing empty commits","startedAt":"2008-10-06T14:57:22Z","lastAt":"2008-10-06T14:57:22Z","messageCount":1,"participants":["Peter Waller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92416","messageId":"19839587.post@talk.nabble.com","threadId":"15800","inReplyTo":null,"subject":"Git filter branch - removing empty commits","fromName":"Peter Waller","fromEmail":"peter.waller@gmail.com","sentAt":"2008-10-06T14:57:22Z","receivedAt":"2008-10-06T14:57:22Z","isPatch":false,"sender":{"key":"peter.waller@gmail.com","avatar":"https://gravatar.com/avatar/c1588c5f6518d6678b34658d1fc3b321fb69c9680f630291d14a3021a4b739d5?d=mp&s=160"},"body":"\nDear List,\n\nI have removed lots of files from my history with a procedure something like\nthis:\n\n1) Clone repository\n\n2) git filter-branch --index-filter 'git rm --quiet -r Archive; git ls-files\n-z '\\''*.png'\\'' '\\''*.eps'\\'' | xargs -0r git rm --quiet; true'\n\n3) git reflog expire --expire=0 --all\n\n4) git prune; git gc\n\nThe problem is that this leaves many empty commits.\n\nThe helpful people over at #git advised I do:\n\ngit filter-branch --commit-filter 'if [ z$1 = z`git rev-parse $3^{tree} 2>\n/dev/null` ]; then skip_commit \"$@\"; else git commit-tree \"$@\"; fi'\n\nBut this gets to about commit 70/1300 and grinds to a halt. I modified\n/usr/libexec/git-core/git-filter-branch to say #!/bin/sh -x, and the result\nwas over 80mb in a few seconds.\n\nI have pasted the last few lines here:\nhttp://rafb.net/p/ABWvCy44.html\n\nIt is like it is following some exponential behaviour and not getting\nanywhere.\n\nAny ideas what is wrong?\n\nI have tried a couple of scripts I have found around that should do the same\nthing, for example:\n\nskip_commit()\n{\n        shift\n        while [[ -n $1 ]] ; do\n                shift\n                map \"$1\"\n                shift\n        done\n}\n\nour_tree=\"$1\"\nour_parent_tree=$(map $3)\n\nif [[ ${our_tree} == $(git rev-parse $(map $3)) ]]; then\n        git commit-tree \"$@\"\nelse\n        skip_commit \"$@\"\nfi\n\nThis goes much faster, but when it reaches the final commit, it says this:\nRef 'refs/heads/master' was deleted\nfatal: Not a valid object name HEAD\n\nAnd not much useful seems to have happened.\n\nAny help appreciated.\n\nRegards,\n\n- Peter\n-- \nView this message in context: http://www.nabble.com/Git-filter-branch---removing-empty-commits-tp19839587p19839587.html\nSent from the git mailing list archive at Nabble.com.\n"}]}