What is a remote-tracking branch, and what is an upstream branch?
Quick Answer
A remote-tracking branch (origin/main) is a local, read-only pointer to where a branch was on the remote at your last fetch. An upstream is the remote branch your local branch is configured to compare/push/pull against — set with git push -u origin feature or git branch --set-upstream-to.
A remote-tracking branch like origin/main is my local snapshot of where main was on the server the last time I fetched — I can't commit to it, it just moves when I fetch. The upstream is the link between my local branch and a remote branch, so that git status can tell me I'm two commits ahead and one behind, and so that a bare git push or git pull knows the target. I set it the first time with git push -u.
git statusshows “ahead 2, behind 1” by comparing your branch to its upstream.git fetchupdatesorigin/*; your local branches don't move until you merge/rebase/pull.- With an upstream set, plain
git pushandgit pullknow where to go.