git branch --set-upstream-to=origin/main main

Category: Git - Core

git branch --set-upstream-to=origin/main main

Set the tracking remote for a branch

Configures the local main branch to track origin/main, so pull, push, and status know the upstream. The -u shorthand is equivalent. Do this once after creating a local branch that mirrors a remote one.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.