#!/usr/bin/env bash GITBIN='/usr/bin/git' # 1. Pull the current branch and also tags, and prune references vanished from remote "$GITBIN" pull -tpf || exit 110 # 2. Pull all branches existing locally mybr="$("$GITBIN" branch --show-current)" while read -r branch do ( printf '\033[1m\033[3mSwitching to %b.\033[0m\n' "$branch" "$GITBIN" switch "$branch" &&\ "$GITBIN" pull &&\ "$GITBIN" switch "$mybr" ) done < <("$GITBIN" branch --list|awk '{print $NF}'|grep -vP "^${mybr}\$")