You forked a repo and need to keep your fork's `main` in sync with upstream. How?
BeginnerScenarioBranching and Merging Workflows
Answer
Situation read → Your fork has only origin; you need the original as a second remote.
What I'd do →
git remote add upstream https://github.com/ORG/REPO.git.git fetch upstream.git switch main && git merge --ff-only upstream/main(orgit rebase upstream/main).git push origin main.
Or use the GitHub UI "Sync fork" button, or gh repo sync OWNER/fork.
Why → --ff-only guarantees your fork's main stays a pure mirror and fails loudly if you committed there by mistake.
Interview tip → Keep your work on topic branches and never commit to your fork's main.
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?Beginner