Opscraft
Git · Lesson 5 of 8 · 3 min read

Remotes and team collaboration

Remotes, fetch, pull and push

git remote -v
git fetch origin                     # download objects and update origin/* (safe, no merge)
git pull                             # fetch + merge (or rebase) into the current branch
git pull --rebase                    # rebase local commits on top of upstream (linear history)
git config --global pull.rebase true
git push -u origin feature/x         # push and set upstream tracking
git branch -vv                       # local branches with upstream and ahead/behind counts
git push origin --delete feature/x

fetch is always safe; pull changes your branch. Configure pull.rebase or pull.ff only to avoid accidental merge commits.

Enlarge diagramYOUR LAPTOPGITHUB (ORIGIN)origin/mainyour copy of GitHub's main, as of thelast fetchmainyour local branch, where you commitmainthe shared brancheveryone pushes tomerge or rebasegit fetchgit pushgit pull = git fetch + merge (or rebase) into your branch. fetch never changes your files.
Figure 1. fetch, pull and push. fetch only updates origin/main, so it is always safe; pull also changes your branch.
Swipe sideways to see all of it, or tap to open it full screen.

Pull requests and code review

A healthy PR workflow:

  • Small PRs (a few hundred lines) reviewed quickly — big PRs get rubber-stamped.
  • Branch protection on main: required reviews (1–2), required status checks (CI, tests, security scans, Terraform plan), up-to-date with base, linear history, no force pushes, signed commits if required.
  • CODEOWNERS automatically requests reviews from the owning team for specific paths (/terraform/prod/ @acme/platform-leads).
  • Merge queues test PRs against the latest main in order, preventing "green PR breaks main" races in busy repos.
  • Signed commits/tags (GPG, SSH or Sigstore gitsign) verify authorship — part of supply-chain security.
Enlarge diagramSmall brancha few hundred lines at mostOpen a PRdescribe the whyCI checkstests, scans, Terraform planReviewCODEOWNERS request the rightteamMerge queuetested against the latest mainMerged to mainprotected: no force-push123456
Figure 2. A healthy pull-request workflow. Nothing reaches main without review and green checks.
Swipe sideways to see all of it, or tap to open it full screen.

Forks vs branches

Internal teams usually work with branches in one repository. Forks suit open source and untrusted contributors (CI on fork PRs must not get secrets — see GitHub Actions).