--- /dev/null
+#!/bin/bash
+# Helper to rewrite all local branches.
+
+rb_one() {
+ local b=$1
+
+ echo "### ${b}"
+ git checkout -q "${b}" || exit
+ if ! git rebase ; then
+ git rebase --abort
+ fi
+}
+
+usage() {
+ cat <<EOF
+Usage: rb-all
+EOF
+ exit 1
+}
+
+main() {
+ if [[ $# -ne 0 ]] ; then
+ usage
+ fi
+
+ local orig b branches
+ orig=$(git rev-parse --abbrev-ref HEAD) || return
+
+ branches=( $(git ls-remote . 'heads/*' | sed 's:.*refs/heads/::') )
+ for b in "${branches[@]}" ; do
+ rb_one "${b}"
+ done
+
+ git checkout -q "${orig}"
+}
+main "$@"