| 123456789101112131415161718 | #!/usr/bin/env bash# ignore non-branch checkoutsif [[ "$3" != "1" ]]; then  exitfi# skip if upstream is already setif git rev-parse --verify --quiet '@{u}' > /dev/null 2>&1; then  exitfi# use upstream/HEAD if it exists, otherwise origin/HEADif git show-ref --verify --quiet refs/remotes/upstream/HEAD; then  git branch --set-upstream-to refs/remotes/upstream/HEADelse  git branch --set-upstream-to refs/remotes/origin/HEADfi
 |