diff --git a/bin/git-rebase-all b/bin/git-rebase-all new file mode 100755 index 0000000..c676d16 --- /dev/null +++ b/bin/git-rebase-all @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +export USAGE='[]' + +# This is the recommended pattern from `man git-sh-setup`. +# +# shellcheck disable=SC1090 +. "$(git --exec-path)/git-sh-setup" + +set -euo pipefail + +case "$#" in + 0) + base=$(git remote show origin | grep "HEAD branch" | awk '{ print $3 }') + ;; + 1) + base="$1" + ;; + *) usage ;; +esac + +git branch --list --format='%(refname:short)' \ + | xargs --verbose -n 1 git rebase "${base}"