# SHIP #!/bin/bash TO_SHIP_TO=$1 CURRENT=`git branch | grep '\*' | awk '{print $2}'` if [ -z $TO_SHIP_TO ]; then echo "First argument has to be one of these branches:" git branch | grep -v $CURRENT exit 1 fi git rebase -i $TO_SHIP_TO REBASE_STATUS=$? if [[ "${REBASE_STATUS}" -ne 0 ]]; then echo "Rebase aborted" exit 0 fi STATUS=`git checkout $TO_SHIP_TO | awk '{print $1}'` if [[ "${STATUS}" =~ error ]]; then echo "Something went terribly wrong! ${STATUS}" git checkout ${CURRENT} exit 1 else git merge ${CURRENT} && \ git push && \ git checkout ${CURRENT} && \ git rebase $TO_SHIP_TO fi