Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is an upstream branch in Git?

SHORT ANSWER

An upstream branch is the remote branch that your local branch is linked to. With it set, plain git pull, git push and git status know where to send and compare changes without extra arguments.

Explain it simply

A local branch with an upstream is like a phone contact with a saved number. You say 'call' and it knows whom.

When you clone, main already tracks origin/main. For a new branch you set the link on first push: git push -u origin feature/x. After that, git status says 'ahead by 2' or 'behind by 1', and git pull and git push work without arguments. See the mapping with git branch -vv. Change it with git branch --set-upstream-to=origin/other.

Example

bash
git switch -c feature/search
git push -u origin feature/search   # -u sets upstream
git branch -vv
# * feature/search 3a4b5c6 [origin/feature/search] Add search box

What to say in the interview

"The upstream is the remote branch a local branch tracks. I set it with git push -u origin branch. Afterwards git pull, git push and git status work without arguments, and status shows how many commits I am ahead or behind."

#git#upstream#tracking

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.