checkout
Branch Checkout Workflow
Section titled “Branch Checkout Workflow”Follow this workflow when creating new branches for development work.
Branch Naming Conventions
Section titled “Branch Naming Conventions”| Prefix | Purpose | Example |
|---|---|---|
feature/ | New features or enhancements | feature/user-auth |
chore/ | Maintenance, refactoring, tooling, docs | chore/update-deps |
hotfix/ | Bug fixes, urgent patches | hotfix/null-pointer-fix |
Naming Rules
Section titled “Naming Rules”- Use lowercase with hyphens:
feature/add-user-authnotfeature/AddUserAuth - Keep names short but descriptive (2-4 words)
- Reference issue numbers when applicable:
hotfix/fix-login-123
Pre-Flight Checks
Section titled “Pre-Flight Checks”Before creating a new branch, verify you’re in a clean state.
Step 1: Check Current Branch
Section titled “Step 1: Check Current Branch”git branch --show-currentIf not on main: You may be in the middle of another task. Either:
- Finish and commit current work, then switch to main
- Stash changes with
git stashif you need to switch temporarily - Abort if you should complete the current task first
Step 2: Check for Uncommitted Changes
Section titled “Step 2: Check for Uncommitted Changes”git status --porcelainIf there are changes: Do not create a new branch. Either:
- Commit the changes to the current branch
- Stash with
git stash push -m "WIP: description" - Discard if truly unwanted with
git checkout .
Step 3: Ensure Main is Up-to-Date
Section titled “Step 3: Ensure Main is Up-to-Date”git pull origin mainThis ensures your new branch starts from the latest code.
Creating the Branch
Section titled “Creating the Branch”Only after all checks pass:
git checkout -b <prefix>/<branch-name>Examples
Section titled “Examples”# Starting a new featuregit checkout -b feature/oauth-login
# Maintenance taskgit checkout -b chore/prettier-config
# Bug fixgit checkout -b hotfix/fix-auth-redirectComplete Workflow Example
Section titled “Complete Workflow Example”# 1. Ensure you're on maingit checkout main
# 2. Pull latest changesgit pull origin main
# 3. Create and switch to new branchgit checkout -b feature/add-notificationsWhen NOT to Create a New Branch
Section titled “When NOT to Create a New Branch”Stop and reconsider if:
- You have uncommitted changes - Commit or stash first
- You’re not on main - You might be abandoning work in progress
- Main is behind remote - Pull first to avoid merge conflicts later
- The task is trivial - Single-line fixes might not need a branch
Quick Reference
Section titled “Quick Reference”| Situation | Action |
|---|---|
| On main, clean state | Safe to create branch |
| On main, uncommitted work | Commit or stash first |
| On feature branch | Finish current work or stash |
| Main behind remote | git pull origin main first |
| Need to switch temporarily | git stash then switch |