#!/bin/sh set -e HASH=`git show $1 --pretty=format:"%H" -q` shift git commit -m "fixup! $HASH" $* [ -n "$(git diff-files)" ] && git stash && DIRTY=1 git rebase $HASH^^ -i --autosquash [ -n "$DIRTY" ] && git stash pop