#!/bin/sh list_branches() { fmt=' d=%(committerdate:short) r=%(refname) echo "$d ${r#refs/heads/}" ' t=`git for-each-ref --sort=-committerdate --format="$fmt" refs/heads` eval "$t" } git update-index --refresh || exit 1 case "$(git diff-index --name-status HEAD)" in '') ;; *) echo "there are local modifications" exit 1 esac # reset first git fetch upstream --progress git reset --hard upstream/trunk # then merge branches git fetch origin --progress git merge --no-edit --no-ff rhe-tools || exit 2 while list_branches && echo -n "> " && read line; do echo "merging branch $line" while :; do if git merge --no-edit --no-ff "$line"; then break fi echo -n "merge failed; press a key to retry" read done done