#!/bin/sh current=$(git rev-parse --abbrev-ref HEAD) git checkout --detach local_branch='\033[32;1m%-30s\t\033[0m' format="printf '$local_branch' %(refname:short); git push . %(if)%(push)%(then)%(push):%(refname)%(else)%(refname):%(refname)%(end)" eval "$(git for-each-ref --shell refs/heads --format="$format")" git checkout "$current"