Skip to content

Branching & Contribution

Simple and practical branching strategy that matches how we actually work in projects.

Follow this pattern: yourname/type/feature-description

Terminal window
# Feature branches
john/feature/user-authentication
sarah/feature/payment-integration
# Bug fixes
mike/fix/login-error
alice/fix/header-styling
# Refactoring
bob/refactor/api-client
mary/refactor/user-service
# Other types
alex/docs/setup-guide
lisa/chore/update-dependencies
Terminal window
# Create new branch from main
git checkout main
git pull origin main
git checkout -b yourname/feature/user-dashboard
Terminal window
# Make changes
git add .
git commit -m "Add user dashboard component"
# Push to GitHub
git push origin yourname/feature/user-dashboard
  • Go to GitHub
  • Click “Compare & pull request”
  • Use the PR template
  • Link to related issue: Closes #123
  • Request review
Terminal window
# Switch back to main and clean up
git checkout main
git pull origin main
git branch -d yourname/feature/user-dashboard
  1. Pick an issue from the project
  2. Assign yourself to the issue
  3. Create branch using issue description
  4. Work on the feature
  5. Create PR that closes the issue
  • Issue #45: “Add dark mode toggle”
  • Branch: yourname/feature/dark-mode-toggle
  • PR title: “Add dark mode toggle (Closes #45)“
Terminal window
# Always start from latest main
git checkout main
git pull origin main
git checkout -b yourname/feature/new-feature
Terminal window
# If main has new changes while you work
git checkout main
git pull origin main
git checkout yourname/feature/new-feature
git merge main
  • One feature per branch
  • Keep PRs small and reviewable
  • Don’t mix different types of changes

Best practices to avoid conflicts:

  • Pull from main frequently (at least daily)
  • Keep branches short-lived (merge within 2-3 days)
  • Communicate with team about file changes
  • Use clear commit messages
Terminal window
# Daily routine to avoid conflicts
git checkout main
git pull origin main
git checkout yourname/feature/current-work
git merge main # or git rebase main for cleaner history

Step-by-step conflict resolution:

  1. Fetch latest changes:
Terminal window
git checkout main
git pull origin main
git checkout yourname/feature/conflicted-branch
git merge main
  1. Git will show conflict markers:
// Example conflict in a file
<<<<<<< HEAD
const apiUrl = 'https://api.staging.example.com';
=======
const apiUrl = 'https://api.production.example.com';
>>>>>>> main
  1. Resolve conflicts manually:
// Choose the correct version or combine both
const apiUrl = process.env.NODE_ENV === 'production'
? 'https://api.production.example.com'
: 'https://api.staging.example.com';
  1. Complete the merge:
Terminal window
git add .
git commit -m "Resolve merge conflict in api configuration"
git push origin yourname/feature/conflicted-branch
Terminal window
# When multiple people add dependencies
# Always accept both changes and remove duplicates manually
git checkout --theirs package.json
npm install # or yarn install
git add package.json package-lock.json

When conflicts seem overwhelming:

  1. Reset and try again:
Terminal window
git merge --abort # Cancel the merge
git checkout main
git pull origin main
# Start over with fresh approach
  1. Ask for help:
  • Share your screen with a teammate
  • Use GitHub’s conflict resolution interface
  • Create a new branch and cherry-pick specific commits
  1. Use VS Code merge tools:
  • Install Git Graph extension
  • Use built-in merge conflict resolver
  • Visual diff makes conflicts easier to understand

If multiple people work on one big feature:

  • Create feature branch: feature/payment-system
  • Everyone branches from it: john/feature/payment-ui, sarah/feature/payment-api
  • Merge individual branches to feature branch
  • Merge feature branch to main when complete

For urgent production fixes:

Terminal window
# Create hotfix branch from main
git checkout main
git pull origin main
git checkout -b yourname/hotfix/critical-security-fix
# After fix, create PR to main immediately
  • Use descriptive PR titles
  • Fill out the PR template completely
  • Link related issues
  • Respond to review feedback quickly
  • Check that code works
  • Verify it follows project guidelines
  • Test the changes if possible
  • Be constructive in feedback