Naming Conventions

Consistent prefixes make branches machine-parseable and instantly readable. Use lowercase, kebab-case only.

Branch naming prefixes, their purpose, and examples.
PrefixPurposeExample
feature/New functionalityfeature/user-auth
fix/Bug fixfix/login-redirect
hotfix/Urgent production fixhotfix/payment-null
release/Release preparationrelease/2.1.0
chore/Maintenance, toolingchore/update-deps
docs/Documentation onlydocs/api-endpoints
test/Test additionstest/auth-coverage
refactor/Code restructure, no logic changerefactor/db-layer
# Good
feature/user-authentication
fix/null-pointer-on-login
release/3.2.0

# Avoid
myBranch
JIRA-1234
wip

Branch Lifecycle

A defined lifecycle keeps branches short-lived and prevents drift from main.

  1. SyncPull latest main before branching โ€” never start from stale code.
  2. CreateBranch with a prefixed, descriptive name. One purpose per branch.
  3. DevelopCommit frequently with conventional messages. Stage intentional hunks, not whole files.
  4. Push & ReviewPublish, open a PR with a clear description. Address feedback in focused follow-up commits.
  5. Merge & DeleteMerge the approved PR. Delete the branch immediately โ€” locally and remotely.
git done                          # 1. sync โ€” fetch + rebase main
git cb feature/auth-refresh       # 2. create
git ap && git cm "feat(auth): add token refresh"  # 3. develop
git publish                       # 4. push + open PR
git co main && git pull           # 5a. after merge lands
git brd feature/auth-refresh      # 5b. delete local

Merge Strategies

How you merge shapes your history. Choose based on what you want preserved.

Comparison of squash merge, rebase merge, and merge commit strategies.
StrategyResultHistoryUse When
Squash MergeOne clean commitSimple, linearSmall features, many WIP commits
Rebase MergeCommits replayed on topLinear, no merge commitPersonal branches, clean log preferred
Merge CommitMerge commit + branch historyComplete, shows topologyLong-lived branches, preserve context
# squash WIP commits before merging
git squash                    # reset --soft HEAD~N then commit

# rebase branch onto latest main
git done                      # fetch + rebase origin/main

# preserve full branch history
git merge --no-ff feature/name

Short-Lived vs Long-Lived

Differences between short-lived and long-lived branches.
CriteriaShort-LivedLong-Lived
LifespanHours to a few daysWeeks to permanent
Conflict riskLow โ€” small diffHigh โ€” drifts from main
Examplesfeature/*, fix/*, chore/*main, develop, release/*
After mergeDelete immediatelyKeep, protect
Merge strategySquash or rebaseMerge commit

Branch Protection

Enforce good habits at the repository level. Apply to main and develop in Gitflow.

  • No direct pushes to main โ€” all changes via PR
  • Require at least 1 approving review before merge
  • Require all CI status checks to pass before merging
  • Dismiss stale approvals when new commits are pushed to the PR
  • Require the branch to be up-to-date with main before merging
  • Restrict who can force-push or delete the protected branch

Cleanup Commands

Stale branches add noise and slow down discovery. Run cleanup regularly.

git cleanup           # delete all locally merged branches
git gone              # find branches whose remote was deleted
git bra               # list all branches local + remote
git brd feature/name  # safe delete (fails if unmerged)
git brD feature/name  # force delete

Build Your Branch Discipline

Consistent naming and short-lived branches compound over time into a codebase that is easy to navigate, review, and debug. Start enforcing conventions today.