#!/usr/bin/env bash export USAGE=' or: ' # This is the recommended pattern from `man git-sh-setup`. # # shellcheck disable=SC1090 . "$(git --exec-path)/git-sh-setup" set -euo pipefail case "$#" in 1) remote='origin' branch="$1" ;; 2) remote="$1" branch="$2" ;; *) usage ;; esac # I often change the fetch refmap to only watch my development branches and # permanent shared ones. Explicitly use a default-ish refmap to undo that and # make this create a named local branch. exec git fetch --refmap='+refs/heads/*:refs/remotes/origin/*' "${remote}" "${branch}:${branch}"