blob: 0855339c8f6efb2a49149e2ff4fde3da4d727b36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/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
if ! mybr="$("$GITBIN" symbolic-ref --short HEAD 2>/dev/null)"; then
printf 'Not on a branch, aborting.\n' >&2
else
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" for-each-ref --format='%(refname:short)' refs/heads/ | grep -vP "^${mybr}\$")
fi
|