Team Workflows & Best Practices
Feature branch workflow, pull requests, stashing, and commit message conventions
Knowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
The feature branch workflow is the industry standard for team Git:
- 1
git switch main && git pull— start from the latest main - 2
git switch -c feat/your-feature— create a feature branch - 3Make commits on the feature branch
- 4
git push -u origin feat/your-feature— push to remote - 5Open a Pull Request (PR) on GitHub — teammates review
- 6Merge the PR (usually via GitHub) → branch is deleted
Pull Requests are not a Git feature — they are a GitHub/GitLab concept. A PR is a request to merge one branch into another, bundled with a diff view and a comment thread for code review.
Stashing — when you need to switch branches but have uncommitted work:
git stash # save dirty working tree to a stack
git switch main # do something on main
git switch - # back to your branch
git stash pop # restore saved changesCommit message conventions — good messages = fast debugging:
# Format: <type>: <short description>
git commit -m "feat: add login with Google"
git commit -m "fix: prevent crash on empty cart"
git commit -m "refactor: extract PaymentService"
git commit -m "docs: update API auth section"Types: feat, fix, refactor, docs, test, chore — this is the standard.
Examples
Full feature branch cycle
The full cycle: branch → commit → push → PR → merge → cleanup. Repeat for every feature or fix.
# 1. Start fresh
git switch main && git pull
# 2. Branch
git switch -c feat/user-avatar
# 3. Work, commit
git add src/Avatar.tsx
git commit -m "feat: add user avatar component"
# 4. Push and open PR
git push -u origin feat/user-avatar
# 5. After PR is merged on GitHub:
git switch main && git pull
git branch -d feat/user-avatarUse stash to switch context mid-work
Stash is a quick way to set aside unfinished work without committing half-done changes.
# You are mid-feature when an urgent bug is reported
git stash # save incomplete work
git switch main && git pull # get latest
git switch -c fix/cart-crash # create fix branch
# fix the bug, commit, push, PR ...
git switch feat/checkout-flow
git stash pop # restore your workHow well did you understand this?