Goal
Use Git the way teams actually work: small commits, feature branches, pull requests, reviews, and safe merges.
The Workflow (end-to-end)
main (stable)
|
+-- feature/my-change (your work)
Steps:
- Sync with main
- Create a branch
- Commit small changes
- Push branch
- Open PR
- Review + fix
- Merge
Commands
Start clean
git status
git pull origin main
Create a feature branch
git checkout -b feature/add-login
Commit in small steps
git add .
git commit -m "Add login form UI"
Push and open PR
git push -u origin feature/add-login
What makes a good PR?
- small and focused
- clear title and description
- includes tests or proof
- easy to review
Merge strategies (what you will see)
- squash merge: one clean commit
- merge commit: preserves branch history
- rebase + merge: linear history
Exercises
- Create a branch and make 2 commits.
- Push branch.
- Make a small fix commit.
- Merge using squash (if available) and pull main again.
Common mistakes
- committing on main directly
- huge PRs that are hard to review
- not pulling latest main before starting
Next Step
Learn how to recover from mistakes: reset, revert, reflog.