git upstream-branch

Get the upstream branch name

Git alias:

upstream-branch = !git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)

Example:

git upstream-branch
origin/main

Compare: