#!/bin/sh

git checkout master
branches="`git branch | sed 's/..//'`"
for branch in ${branches} ;do
	echo git checkout $branch
	git checkout $branch
	for new_root in "${@:-HEAD}"; do
		new_root_hash=`git log -n1 --format=%H "$new_root"`
		echo "$new_root_hash"
	done >.git/info/grafts
	git filter-branch -f
done
rm .git/info/grafts
`dirname $0`/git-gc-all-ferocious --aggressive
