Skip to main content

git/gm

1#!/usr/bin/env bash
2# Switch to my main branch and pull any changes from the remote.
4set -o errexit
5set -o nounset
7ROOT="$(git rev-parse --show-toplevel)"
9REPO_NAME="$(basename "$ROOT")"
10if git remote get-url origin | grep "phaenna-mac-mini" >/dev/null; then
11 ensure_on_tailnet.sh "alexwlchan.github"
12fi
14# Checking for the branch first is a bit slower, but avoids a potentially
15# confusing warning immediately before the pull:
17# Already on 'main'
18# Your branch is up to date with 'origin/main'.
20# The `--quiet` flag is to avoid a warning like:
22# Your branch is behind 'origin/main' by 6 commits, and can be
23# fast-forwarded.
25# because I know I'm about to do that.
26if [[ $(gcb) != $(_get_primary_branch) ]]
27then
28 print_info "-> git checkout $(_get_primary_branch) (was on $(gcb))"
29 git checkout "$(_get_primary_branch)" --quiet
30 echo ""
31fi
33# This avoids any clashes with other programs called "gp", e.g. at one
34# point I had gitpython in my PATH
35$(dirname "$0")/gp
37echo ""
39cleanup_branches