Git

Lesson 04

Branch naming and upstream

Create topic branches with clear names and set upstream tracking so future pushes and pulls target the right remote branch.

Good Code

branch-start.sh
# Topic branch name tells teammates what this work is about.
git switch -c feature/git-track-lessons
git push -u origin feature/git-track-lessons
git status --short --branch

Bad Code

branch-start.sh
# Committing directly on main raises the cost of mistakes.
git switch main
git commit -am "changes"
git push origin HEAD

Review Notes

What to review

Good Code

The good version creates a named topic branch, publishes it with upstream tracking, and checks the branch state.

Bad Code

The bad version commits on main and pushes HEAD without a clear target. That makes accidental pushes harder to spot in review.

Takeaways

  • A branch should tell the team what kind of work it contains and where it syncs by default.