Git Workflow
Overview
Git workflow is the sequence for branching, committing, reviewing, and merging work safely.
Why It Matters
A clean workflow reduces merge pain, makes history readable, and lowers release risk.
Core Concepts
- Keep branches focused.
- Commit logical units of work.
- Rebase or merge consistently with team norms.
Mental Models
Think in checkpoints. Each commit should leave the codebase in a sensible state.
Best Practices
- Make small commits with clear messages.
- Pull or rebase before review if needed.
- Resolve conflicts early.
Common Mistakes
- Long-lived branches with many unrelated changes.
- Mixing formatting with behavior changes.
- Forgetting to sync with main.
Trade-offs
Rebasing keeps history tidy, while merge commits preserve branch context. Pick one team standard and be consistent.
Decision Framework
| Situation | Prefer |
|---|---|
| Small feature branch | Rebase or squash |
| Shared integration branch | Merge carefully |
| Hotfix | Fastest safe path |
Examples
- Commit message:
fix auth redirect after token refresh - Branch name:
feature/settings-permissions
Checklists
- Is the branch up to date?
- Are commits understandable?
- Did I avoid unrelated file churn?
Senior Engineer Notes
Senior engineers treat Git as a collaboration tool, not just a local backup system. Good history helps future debugging and release tracking.